From 4e3e721650fb7f6c826bf77c067a96eda14886fd Mon Sep 17 00:00:00 2001 From: scottMan1001 <3141996514@qq.com> Date: Tue, 11 Jul 2023 11:52:54 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20esbuild=E5=A2=9E=E5=8A=A0=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E5=BC=80=E5=8F=91=E6=A8=A1=E5=BC=8F=E4=B8=8B=E5=AF=B9?= =?UTF-8?q?cnosole=20debugger=E7=9A=84=E5=A4=84=E7=90=86=20(#2907)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/vite-config/src/config/application.ts | 2 +- internal/vite-config/src/config/common.ts | 6 +++--- internal/vite-config/src/config/package.ts | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/vite-config/src/config/application.ts b/internal/vite-config/src/config/application.ts index eb8d58420..4b3294277 100644 --- a/internal/vite-config/src/config/application.ts +++ b/internal/vite-config/src/config/application.ts @@ -89,7 +89,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) { plugins, }; - const mergedConfig = mergeConfig(commonConfig, applicationConfig); + const mergedConfig = mergeConfig(commonConfig(mode), applicationConfig); return mergeConfig(mergedConfig, overrides); }); diff --git a/internal/vite-config/src/config/common.ts b/internal/vite-config/src/config/common.ts index 3f18836a5..dae0409ab 100644 --- a/internal/vite-config/src/config/common.ts +++ b/internal/vite-config/src/config/common.ts @@ -2,12 +2,12 @@ import { presetTypography, presetUno } from 'unocss'; import UnoCSS from 'unocss/vite'; import { type UserConfig } from 'vite'; -const commonConfig: UserConfig = { +const commonConfig: (mode: string) => UserConfig = (mode) => ({ server: { host: true, }, esbuild: { - drop: ['debugger'], + drop: mode === 'procution' ? ['console', 'debugger'] : [], }, build: { reportCompressedSize: false, @@ -22,6 +22,6 @@ const commonConfig: UserConfig = { presets: [presetUno(), presetTypography()], }), ], -}; +}); export { commonConfig }; diff --git a/internal/vite-config/src/config/package.ts b/internal/vite-config/src/config/package.ts index cb6dd1911..ab8385271 100644 --- a/internal/vite-config/src/config/package.ts +++ b/internal/vite-config/src/config/package.ts @@ -14,7 +14,7 @@ interface DefineOptions { function definePackageConfig(defineOptions: DefineOptions = {}) { const { overrides = {} } = defineOptions; const root = process.cwd(); - return defineConfig(async () => { + return defineConfig(async ({ mode }) => { const { dependencies = {}, peerDependencies = {} } = await readPackageJSON(root); const packageConfig: UserConfig = { build: { @@ -33,7 +33,7 @@ function definePackageConfig(defineOptions: DefineOptions = {}) { }), ], }; - const mergedConfig = mergeConfig(commonConfig, packageConfig); + const mergedConfig = mergeConfig(commonConfig(mode), packageConfig); return mergeConfig(mergedConfig, overrides); });