fix: 消除前端循环分块导致的骨架屏
This commit is contained in:
parent
6b0bf59e74
commit
d32494ca12
@ -11,15 +11,21 @@ export default defineConfig({
|
||||
cssCodeSplit: false,
|
||||
modulePreload: false,
|
||||
rollupOptions: {
|
||||
onwarn(warning, warn) {
|
||||
// Manually splitting packages that depend on each other can create a circular chunk graph.
|
||||
// That graph built successfully in the past but crashed before React mounted, leaving only
|
||||
// the static skeleton on screen. Treat it as a release-blocking error from now on.
|
||||
if (warning.code === 'CIRCULAR_CHUNK') {
|
||||
throw new Error(`Circular production chunk: ${warning.message}`)
|
||||
}
|
||||
warn(warning)
|
||||
},
|
||||
output: {
|
||||
entryFileNames: 'assets/[name]-[hash].js',
|
||||
chunkFileNames(chunkInfo) {
|
||||
if (chunkInfo.name === 'app-shell') return 'assets/app-shell-[hash].js'
|
||||
if (chunkInfo.name === 'app-api') return 'assets/app-api-[hash].js'
|
||||
if (chunkInfo.name === 'react-vendor') return 'assets/react-vendor-[hash].js'
|
||||
if (chunkInfo.name === 'antd-vendor') return 'assets/antd-vendor-[hash].js'
|
||||
if (chunkInfo.name === 'charts-vendor') return 'assets/charts-vendor-[hash].js'
|
||||
if (chunkInfo.name === 'data-vendor') return 'assets/data-vendor-[hash].js'
|
||||
if (chunkInfo.name === 'vendor') return 'assets/vendor-[hash].js'
|
||||
return 'assets/[name]-[hash].js'
|
||||
},
|
||||
assetFileNames(assetInfo) {
|
||||
@ -32,41 +38,8 @@ export default defineConfig({
|
||||
const normalizedId = id.replace(/\\/g, '/')
|
||||
|
||||
if (normalizedId.includes('node_modules') || normalizedId.includes('/.vite/deps/')) {
|
||||
if (
|
||||
normalizedId.includes('/react/') ||
|
||||
normalizedId.includes('react-dom') ||
|
||||
normalizedId.includes('react-router') ||
|
||||
normalizedId.includes('@remix-run/router') ||
|
||||
normalizedId.includes('react_jsx-runtime') ||
|
||||
normalizedId.includes('scheduler')
|
||||
) {
|
||||
return 'react-vendor'
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedId.includes('antd') ||
|
||||
normalizedId.includes('@ant-design') ||
|
||||
normalizedId.includes('@ant-design/pro-components') ||
|
||||
normalizedId.includes('/rc-')
|
||||
) {
|
||||
return 'antd-vendor'
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedId.includes('echarts') ||
|
||||
normalizedId.includes('zrender') ||
|
||||
normalizedId.includes('recharts')
|
||||
) {
|
||||
return 'charts-vendor'
|
||||
}
|
||||
|
||||
if (
|
||||
normalizedId.includes('axios') ||
|
||||
normalizedId.includes('@cubejs-client')
|
||||
) {
|
||||
return 'data-vendor'
|
||||
}
|
||||
|
||||
// Keep mutually dependent third-party packages in one chunk. React, Ant Design,
|
||||
// charts and Cube clients share runtime helpers and cannot be split safely by path.
|
||||
return 'vendor'
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user