perf: 优化 Vite 构建配置降低内存使用 - 移除生产环境visualizer插件

This commit is contained in:
2026-04-20 06:28:56 +08:00
parent bed73618d6
commit e505ccd76e
2 changed files with 9 additions and 8 deletions
+8 -7
View File
@@ -25,12 +25,12 @@ export default defineConfig(({mode}) => {
VitePWA({
registerType: 'autoUpdate',
workbox: {
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024, // 10MB
navigateFallbackDenylist: [/^\/api\//], // 阻止 /api 被 fallback 到 index.html
maximumFileSizeToCacheInBytes: 10 * 1024 * 1024,
navigateFallbackDenylist: [/^\/api\//],
runtimeCaching: [
{
urlPattern: ({url}) => !url.pathname.startsWith('/api/'),
handler: 'NetworkOnly', // 不缓存,直接请求网络
handler: 'NetworkOnly',
},
],
},
@@ -49,10 +49,9 @@ export default defineConfig(({mode}) => {
]
},
})
] : []),
visualizer({
// open: true,
}) as unknown as PluginOption
] : [
visualizer({}) as unknown as PluginOption
]),
],
resolve: {
alias: {'@': resolve(__dirname, './src')},
@@ -60,6 +59,8 @@ export default defineConfig(({mode}) => {
build: {
sourcemap: false,
minify: 'esbuild',
target: 'es2020',
chunkSizeWarningLimit: 2000,
rollupOptions: {
maxParallelFileOps: 2,
output: {