feat: esbuild增加不同开发模式下对cnosole debugger的处理 (#2907)

This commit is contained in:
scottMan1001 2023-07-11 11:52:54 +08:00 committed by GitHub
parent c6e135195a
commit 4e3e721650
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -89,7 +89,7 @@ function defineApplicationConfig(defineOptions: DefineOptions = {}) {
plugins,
};
const mergedConfig = mergeConfig(commonConfig, applicationConfig);
const mergedConfig = mergeConfig(commonConfig(mode), applicationConfig);
return mergeConfig(mergedConfig, overrides);
});

View File

@ -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 };

View File

@ -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);
});