perf: 优化构建速度 (#112)

This commit is contained in:
HavocZ 2023-08-23 11:59:22 +08:00 committed by GitHub
parent 2cd7b161e8
commit 88033a823d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -47,23 +47,29 @@ export default (configEnv: ConfigEnv): UserConfigExport => {
}, },
build: { build: {
/** 消除打包大小超过 500kb 警告 */ /** 消除打包大小超过 500kb 警告 */
chunkSizeWarningLimit: 2000, chunkSizeWarningLimit: 2048,
/** Vite 2.6.x 以上需要配置 minify: "terser", terserOptions 才能生效 */ /** 禁用 gzip 压缩大小报告 */
minify: "terser", reportCompressedSize: false,
/** 在打包代码时移除 console.log、debugger 和 注释 */ /** 打包后静态资源目录 */
terserOptions: { assetsDir: "static",
compress: { /** 分块策略 */
drop_console: false, rollupOptions: {
drop_debugger: true, output: {
pure_funcs: ["console.log"] manualChunks: {
}, vue: ["vue", "vue-router", "pinia"],
format: { elment: ["element-plus", "@element-plus/icons-vue"],
/** 删除注释 */ vxe: ["vxe-table", "vxe-table-plugin-element", "xe-utils"]
comments: false }
}
} }
}, },
/** 打包后静态资源目录 */ esbuild: {
assetsDir: "static" /** 在打包代码时移除 console.log */
pure: ["console.log"],
/** 在打包代码时移除 debugger */
drop: ["debugger"],
/** 在打包代码时移除所有注释 */
legalComments: "none"
}, },
/** Vite 插件 */ /** Vite 插件 */
plugins: [ plugins: [