From e23d82dedb56f03082709300c5d7ab1d3bfb7aef Mon Sep 17 00:00:00 2001 From: zhangdaiscott Date: Thu, 24 Aug 2023 22:49:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=93=E5=8C=85=E5=8E=BBlog=E4=B8=8D?= =?UTF-8?q?=E7=94=9F=E6=95=88=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .env.development | 3 --- .env.production | 3 --- vite.config.ts | 17 +++++++---------- 3 files changed, 7 insertions(+), 16 deletions(-) diff --git a/.env.development b/.env.development index d7894be..0e5eb14 100644 --- a/.env.development +++ b/.env.development @@ -7,9 +7,6 @@ VITE_PUBLIC_PATH = / # 跨域代理,您可以配置多个 ,请注意,没有换行符 VITE_PROXY = [["/jeecgboot","http://localhost:8080/jeecg-boot"],["/upload","http://localhost:3300/upload"]] -# 控制台不输出 -VITE_DROP_CONSOLE = false - #后台接口父地址(必填) VITE_GLOB_API_URL=/jeecgboot diff --git a/.env.production b/.env.production index de33204..19a9629 100644 --- a/.env.production +++ b/.env.production @@ -4,9 +4,6 @@ VITE_USE_MOCK = true # 发布路径 VITE_PUBLIC_PATH = / -# 控制台不输出 -VITE_DROP_CONSOLE = true - # 是否启用gzip或brotli压缩 # 选项值: gzip | brotli | none # 如果需要多个可以使用“,”分隔 diff --git a/vite.config.ts b/vite.config.ts index b1a11a6..f2324a6 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -27,7 +27,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { // The boolean type read by loadEnv is a string. This function can be converted to boolean type const viteEnv = wrapperEnv(env); - const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY, VITE_DROP_CONSOLE } = viteEnv; + const { VITE_PORT, VITE_PUBLIC_PATH, VITE_PROXY } = viteEnv; const isBuild = command === 'build'; @@ -65,18 +65,15 @@ export default ({ command, mode }: ConfigEnv): UserConfig => { target: 'es2015', cssTarget: 'chrome80', outDir: OUTPUT_DIR, - terserOptions: { - compress: { - keep_infinity: true, - // Used to delete console in production environment - drop_console: VITE_DROP_CONSOLE, - drop_debugger: true, - }, - }, - // Turning off brotliSize display can slightly reduce packaging time + // 关闭brotliSize显示可以稍微减少打包时间 reportCompressedSize: false, + // 提高超大静态资源警告大小 chunkSizeWarningLimit: 2000, }, + esbuild: { + //清除全局的console.log和debug + drop: isBuild ? ['console', 'debugger'] : [], + }, define: { // setting vue-i18-next // Suppress warning