mirror of
https://github.com/fastapiadmin/FastapiAdmin.git
synced 2026-10-04 17:14:21 +00:00
perf(frontend): 优化构建配置以提高性能和减小包体积
增加 Node.js 内存限制以避免构建时内存溢出 调整分包策略并添加文件命名规则以优化缓存 启用代码压缩并移除 console 和 debugger 语句
This commit is contained in:
@@ -5,7 +5,7 @@
|
|||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite",
|
"dev": "vite",
|
||||||
"build": "vite build",
|
"build": "NODE_OPTIONS=--max-old-space-size=4096 vite build",
|
||||||
"preview": "vite preview"
|
"preview": "vite preview"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+17
-7
@@ -38,14 +38,24 @@ export default defineConfig(({ command, mode }) => {
|
|||||||
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
chunkSizeWarningLimit: 1600, // 打包文件大小限制
|
chunkSizeWarningLimit: 2000,
|
||||||
rollupOptions: { // 打包配置
|
rollupOptions: {
|
||||||
output: { //
|
output: {
|
||||||
manualChunks(id) { // 手动分包
|
manualChunks(id) {
|
||||||
if (id.includes('node_modules')) {
|
if (id.includes('node_modules')) {
|
||||||
return id.toString().split('node_modules/')[1].split('/')[0].toString(); // 根据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