From 4a81c7ac494ed2efe81fecf12289b3d68541bd8d Mon Sep 17 00:00:00 2001 From: XGHeaven Date: Wed, 4 Sep 2024 14:46:03 +0800 Subject: [PATCH] feat: improve miniapp --- .github/workflows/pr-temp.yml | 31 +++++++++++++++++++ packages/ice/templates/core/env.ts.ejs | 2 +- packages/plugin-miniapp/src/miniapp/index.ts | 1 + .../src/miniapp/webpack/module.ts | 12 ++++++- 4 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/pr-temp.yml diff --git a/.github/workflows/pr-temp.yml b/.github/workflows/pr-temp.yml new file mode 100644 index 0000000000..da285acc0a --- /dev/null +++ b/.github/workflows/pr-temp.yml @@ -0,0 +1,31 @@ +name: PR Release + +on: + pull_request: + +jobs: + release: + name: Release + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [18] + + steps: + - name: Checkout Branch + uses: actions/checkout@v3 + + - name: Install pnpm + uses: pnpm/action-setup@v4 + + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v3 + with: + node-version: ${{ matrix.node-version }} + cache: 'pnpm' + + - name: Setup + run: pnpm run setup + + - run: pnpx pkg-pr-new publish './packages/*' diff --git a/packages/ice/templates/core/env.ts.ejs b/packages/ice/templates/core/env.ts.ejs index fd177327ad..55af9bdf7c 100644 --- a/packages/ice/templates/core/env.ts.ejs +++ b/packages/ice/templates/core/env.ts.ejs @@ -11,7 +11,7 @@ export const isKuaiShouMiniProgram = isClient && import.meta.target === 'kuaisho export const isWeChatMiniProgram = isClient && import.meta.target === 'wechat-miniprogram'; export const isKraken = isClient && import.meta.target === 'kraken'; export const isQuickApp = false; // Now ice.js will not implement quick app target. -export const isMiniApp = isAliMiniApp || isByteDanceMicroApp || isBaiduSmartProgram || isKuaiShouMiniProgram || isWeChatMiniProgram; +export const isMiniApp = isAliMiniApp;// in universal-env, isMiniApp is equals to isAliMiniApp // Following variables are runtime executed envs. // See also @uni/env. diff --git a/packages/plugin-miniapp/src/miniapp/index.ts b/packages/plugin-miniapp/src/miniapp/index.ts index 31150f480c..8128c232a1 100644 --- a/packages/plugin-miniapp/src/miniapp/index.ts +++ b/packages/plugin-miniapp/src/miniapp/index.ts @@ -80,6 +80,7 @@ const getMiniappTask = ({ enableCache: false, plugins, loaders: module?.rules, + assetsManifest: false, optimization: { sideEffects: true, usedExports: true, diff --git a/packages/plugin-miniapp/src/miniapp/webpack/module.ts b/packages/plugin-miniapp/src/miniapp/webpack/module.ts index dc0190e5a5..6e252b9015 100644 --- a/packages/plugin-miniapp/src/miniapp/webpack/module.ts +++ b/packages/plugin-miniapp/src/miniapp/webpack/module.ts @@ -57,13 +57,23 @@ export class MiniWebpackModule { test: REG_TEMPLATE, type: 'asset/resource', generator: { - filename({ filename }) { + filename: ({ filename }) => { const extname = path.extname(filename); return filename.replace(`${this.sourceRoot}/`, '').replace(extname, fileType.templ); }, }, use: [this.getLoader(path.resolve(__dirname, './loaders/miniTemplateLoader'))], }, + { + test: /\.wxss$/, + type: 'asset/resource', + generator: { + filename: ({ filename }) => { + const extname = path.extname(filename); + return filename.replace(`${this.sourceRoot}/`, '').replace(extname, fileType.style); + }, + }, + }, ]; return { rules }; }