mirror of
https://github.com/truewhile/MeBox.git
synced 2026-10-08 22:36:37 +08:00
优化
This commit is contained in:
@@ -24,5 +24,25 @@ export default defineConfig({
|
||||
build: {
|
||||
outDir: 'dist',
|
||||
sourcemap: false,
|
||||
rollupOptions: {
|
||||
output: {
|
||||
// 只拆哈希长期稳定的核心库:业务代码发版后用户只需重新下载变小的
|
||||
// 业务 chunk,核心 vendor 走浏览器长缓存。其余依赖保持 Vite 默认
|
||||
// 分块,避免把 hls.js 等懒加载库拖进首屏。
|
||||
manualChunks(id) {
|
||||
if (!id.includes('node_modules')) return undefined
|
||||
if (/[\\/]node_modules[\\/](react|react-dom|react-router|react-router-dom|scheduler)[\\/]/.test(id)) {
|
||||
return 'vendor-react'
|
||||
}
|
||||
if (/[\\/]node_modules[\\/](axios|zustand)[\\/]/.test(id)) {
|
||||
return 'vendor-data'
|
||||
}
|
||||
if (/[\\/]node_modules[\\/]framer-motion[\\/]/.test(id)) {
|
||||
return 'vendor-motion'
|
||||
}
|
||||
return undefined
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user