mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-09-21 20:55:14 +00:00
perf(frontend): 优化构建配置以提高性能和减小包体积
增加 Node.js 内存限制以避免构建时内存溢出 调整分包策略并添加文件命名规则以优化缓存 启用代码压缩并移除 console 和 debugger 语句
This commit is contained in:
+17
-7
@@ -38,14 +38,24 @@ export default defineConfig(({ command, mode }) => {
|
||||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
||||
},
|
||||
build: {
|
||||
chunkSizeWarningLimit: 1600, // 打包文件大小限制
|
||||
rollupOptions: { // 打包配置
|
||||
output: { //
|
||||
manualChunks(id) { // 手动分包
|
||||
if (id.includes('node_modules')) {
|
||||
return id.toString().split('node_modules/')[1].split('/')[0].toString(); // 根据node_modules中的包名进行分包
|
||||
}
|
||||
chunkSizeWarningLimit: 2000,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (id.includes('node_modules')) {
|
||||
return id.toString().split('node_modules/')[1].split('/')[0].toString();
|
||||
}
|
||||
},
|
||||
entryFileNames: `assets/[name]-[hash].js`,
|
||||
chunkFileNames: `assets/[name]-[hash].js`,
|
||||
assetFileNames: `assets/[name]-[hash].[ext]`
|
||||
}
|
||||
},
|
||||
minify: false,
|
||||
terserOptions: {
|
||||
compress: {
|
||||
drop_console: true,
|
||||
drop_debugger: true
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user