From e1414ee07f142c229df411843c3faab5810b5d3c Mon Sep 17 00:00:00 2001 From: feige996 <1020102647@qq.com> Date: Tue, 16 Sep 2025 18:49:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(optimization):=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=86=E5=8C=85=E4=BC=98=E5=8C=96=E5=92=8C=E5=BC=82=E6=AD=A5?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81=EF=BC=8C=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E7=9B=B8=E5=85=B3=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- manifest.config.ts | 3 +++ tsconfig.json | 2 ++ vite.config.ts | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/manifest.config.ts b/manifest.config.ts index 50c2dc3..46d3876 100644 --- a/manifest.config.ts +++ b/manifest.config.ts @@ -135,6 +135,9 @@ export default defineManifestConfig({ 'mp-alipay': { usingComponents: true, styleIsolation: 'shared', + optimization: { + subPackages: true, + }, }, 'mp-baidu': { usingComponents: true, diff --git a/tsconfig.json b/tsconfig.json index 0b55344..3696728 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,6 +17,8 @@ "miniprogram-api-typings", "wot-design-uni/global.d.ts", "z-paging/types", + "./src/types/async-component.d.ts", + "./src/types/async-import.d.ts", "./src/typings.d.ts" ], "allowJs": true, diff --git a/vite.config.ts b/vite.config.ts index f75c7c1..cbfbc14 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -70,6 +70,18 @@ export default defineConfig(({ command, mode }) => { UniLayouts(), UniPlatform(), UniManifest(), + // Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行 + Optimization({ + enable: { + 'optimization': true, + 'async-import': true, + 'async-component': true, + }, + dts: { + base: 'src/types', + }, + logger: true, + }), // UniXXX 需要在 Uni 之前引入 { // 临时解决 dcloudio 官方的 @dcloudio/uni-mp-compiler 出现的编译 BUG @@ -90,19 +102,6 @@ export default defineConfig(({ command, mode }) => { dirs: ['src/hooks'], // 自动导入 hooks vueTemplate: true, // default false }), - // Optimization 插件需要 page.json 文件,故应在 UniPages 插件之后执行 - Optimization({ - enable: { - 'optimization': true, - 'async-import': true, - 'async-component': true, - }, - dts: { - base: 'src/types', - }, - logger: false, - }), - ViteRestart({ // 通过这个插件,在修改vite.config.js文件则不需要重新运行也生效配置 restart: ['vite.config.js'],