Commit 4e3e721650fb7f6c826bf77c067a96eda14886fd
Committed by
GitHub
1 parent
c6e13519
feat: esbuild增加不同开发模式下对cnosole debugger的处理 (#2907)
Showing
3 changed files
with
6 additions
and
6 deletions
internal/vite-config/src/config/application.ts
... | ... | @@ -89,7 +89,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { |
89 | 89 | plugins, |
90 | 90 | }; |
91 | 91 | |
92 | - const mergedConfig = mergeConfig(commonConfig, applicationConfig); | |
92 | + const mergedConfig = mergeConfig(commonConfig(mode), applicationConfig); | |
93 | 93 | |
94 | 94 | return mergeConfig(mergedConfig, overrides); |
95 | 95 | }); | ... | ... |
internal/vite-config/src/config/common.ts
... | ... | @@ -2,12 +2,12 @@ import { presetTypography, presetUno } from 'unocss'; |
2 | 2 | import UnoCSS from 'unocss/vite'; |
3 | 3 | import { type UserConfig } from 'vite'; |
4 | 4 | |
5 | -const commonConfig: UserConfig = { | |
5 | +const commonConfig: (mode: string) => UserConfig = (mode) => ({ | |
6 | 6 | server: { |
7 | 7 | host: true, |
8 | 8 | }, |
9 | 9 | esbuild: { |
10 | - drop: ['debugger'], | |
10 | + drop: mode === 'procution' ? ['console', 'debugger'] : [], | |
11 | 11 | }, |
12 | 12 | build: { |
13 | 13 | reportCompressedSize: false, |
... | ... | @@ -22,6 +22,6 @@ const commonConfig: UserConfig = { |
22 | 22 | presets: [presetUno(), presetTypography()], |
23 | 23 | }), |
24 | 24 | ], |
25 | -}; | |
25 | +}); | |
26 | 26 | |
27 | 27 | export { commonConfig }; | ... | ... |
internal/vite-config/src/config/package.ts
... | ... | @@ -14,7 +14,7 @@ interface DefineOptions { |
14 | 14 | function definePackageConfig(defineOptions: DefineOptions = {}) { |
15 | 15 | const { overrides = {} } = defineOptions; |
16 | 16 | const root = process.cwd(); |
17 | - return defineConfig(async () => { | |
17 | + return defineConfig(async ({ mode }) => { | |
18 | 18 | const { dependencies = {}, peerDependencies = {} } = await readPackageJSON(root); |
19 | 19 | const packageConfig: UserConfig = { |
20 | 20 | build: { |
... | ... | @@ -33,7 +33,7 @@ function definePackageConfig(defineOptions: DefineOptions = {}) { |
33 | 33 | }), |
34 | 34 | ], |
35 | 35 | }; |
36 | - const mergedConfig = mergeConfig(commonConfig, packageConfig); | |
36 | + const mergedConfig = mergeConfig(commonConfig(mode), packageConfig); | |
37 | 37 | |
38 | 38 | return mergeConfig(mergedConfig, overrides); |
39 | 39 | }); | ... | ... |