From 88033a823d825006787382793249e9bfcae80880 Mon Sep 17 00:00:00 2001 From: HavocZ Date: Wed, 23 Aug 2023 11:59:22 +0800 Subject: [PATCH] =?UTF-8?q?perf:=20=E4=BC=98=E5=8C=96=E6=9E=84=E5=BB=BA?= =?UTF-8?q?=E9=80=9F=E5=BA=A6=20(#112)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vite.config.ts | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/vite.config.ts b/vite.config.ts index 37c8f42c..32385c1c 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -47,23 +47,29 @@ export default (configEnv: ConfigEnv): UserConfigExport => { }, build: { /** 消除打包大小超过 500kb 警告 */ - chunkSizeWarningLimit: 2000, - /** Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 */ - minify: "terser", - /** 在打包代码时移除 console.log、debugger 和 注释 */ - terserOptions: { - compress: { - drop_console: false, - drop_debugger: true, - pure_funcs: ["console.log"] - }, - format: { - /** 删除注释 */ - comments: false - } - }, + chunkSizeWarningLimit: 2048, + /** 禁用 gzip 压缩大小报告 */ + reportCompressedSize: false, /** 打包后静态资源目录 */ - assetsDir: "static" + assetsDir: "static", + /** 分块策略 */ + rollupOptions: { + output: { + manualChunks: { + vue: ["vue", "vue-router", "pinia"], + elment: ["element-plus", "@element-plus/icons-vue"], + vxe: ["vxe-table", "vxe-table-plugin-element", "xe-utils"] + } + } + } + }, + esbuild: { + /** 在打包代码时移除 console.log */ + pure: ["console.log"], + /** 在打包代码时移除 debugger */ + drop: ["debugger"], + /** 在打包代码时移除所有注释 */ + legalComments: "none" }, /** Vite 插件 */ plugins: [