From b1dbeecd4993093d7c5ebec1d0f537f1e0a932f0 Mon Sep 17 00:00:00 2001 From: april <1317795103@qq.com> Date: Thu, 31 Aug 2023 17:13:15 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9E=84=E5=BB=BA=E4=BD=93=E7=A7=AF?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Former-commit-id: 21a1d9e8a99c8b45db72cffc90346c61456df71d --- package.json | 1 + vite.config.ts | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 9ef5bee9..af84be34 100644 --- a/package.json +++ b/package.json @@ -57,6 +57,7 @@ "pinia": "^2.0.33", "screenfull": "^6.0.0", "sortablejs": "^1.15.0", + "terser": "^5.19.3", "vue": "^3.3.4", "vue-i18n": "9.2.2", "vue-router": "^4.2.0", diff --git a/vite.config.ts b/vite.config.ts index 78fcf4f0..73fdbe2f 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -187,7 +187,6 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { "element-plus/es/components/notification/style/css", "@vueuse/core", "sortablejs", - "path-to-regexp", "echarts", "@wangeditor/editor", @@ -196,5 +195,20 @@ export default defineConfig(({ mode }: ConfigEnv): UserConfig => { "codemirror", ], }, + // 构建 + build: { + chunkSizeWarningLimit: 2000, // 消除打包大小超过500kb警告 + minify: "terser", // Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 + terserOptions: { + compress: { + keep_infinity: true, // 防止 Infinity 被压缩成 1/0,这可能会导致 Chrome 上的性能问题 + drop_console: true, // 生产环境去除 console + drop_debugger: true, // 生产环境去除 debugger + }, + format: { + comments: false, // 删除注释 + }, + }, + }, }; });