diff --git a/package.json b/package.json index 9ef5bee..af84be3 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 78fcf4f..73fdbe2 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, // 删除注释 + }, + }, + }, }; });