Update vite.config.ts
This commit is contained in:
@@ -32,6 +32,66 @@ export default defineConfig(({ mode }) => {
|
|||||||
target: 'es2020',
|
target: 'es2020',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
// Build configuration for code splitting
|
||||||
|
build: {
|
||||||
|
rollupOptions: {
|
||||||
|
output: {
|
||||||
|
// Manual chunk splitting for better code splitting
|
||||||
|
manualChunks: (id) => {
|
||||||
|
// Vendor chunks - separate large dependencies
|
||||||
|
if (id.includes('node_modules')) {
|
||||||
|
// React and React DOM together
|
||||||
|
if (id.includes('react') || id.includes('react-dom') || id.includes('react-router')) {
|
||||||
|
return 'vendor-react';
|
||||||
|
}
|
||||||
|
// Chart libraries
|
||||||
|
if (id.includes('apexcharts') || id.includes('recharts')) {
|
||||||
|
return 'vendor-charts';
|
||||||
|
}
|
||||||
|
// UI libraries
|
||||||
|
if (id.includes('@radix-ui') || id.includes('framer-motion')) {
|
||||||
|
return 'vendor-ui';
|
||||||
|
}
|
||||||
|
// Other large vendors
|
||||||
|
return 'vendor';
|
||||||
|
}
|
||||||
|
// Page chunks - each page gets its own chunk
|
||||||
|
if (id.includes('/pages/')) {
|
||||||
|
const match = id.match(/\/pages\/([^/]+)/);
|
||||||
|
if (match) {
|
||||||
|
const pageName = match[1];
|
||||||
|
// Group by module
|
||||||
|
if (pageName === 'Planner' || id.includes('/Planner/')) {
|
||||||
|
return 'pages-planner';
|
||||||
|
}
|
||||||
|
if (pageName === 'Writer' || id.includes('/Writer/')) {
|
||||||
|
return 'pages-writer';
|
||||||
|
}
|
||||||
|
if (pageName === 'Thinker' || id.includes('/Thinker/')) {
|
||||||
|
return 'pages-thinker';
|
||||||
|
}
|
||||||
|
if (pageName === 'Settings' || id.includes('/Settings/')) {
|
||||||
|
return 'pages-settings';
|
||||||
|
}
|
||||||
|
if (pageName === 'Billing' || id.includes('/Billing/')) {
|
||||||
|
return 'pages-billing';
|
||||||
|
}
|
||||||
|
// Individual page chunks for others
|
||||||
|
return `page-${pageName.toLowerCase()}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
// Optimize chunk file names
|
||||||
|
chunkFileNames: 'assets/js/[name]-[hash].js',
|
||||||
|
entryFileNames: 'assets/js/[name]-[hash].js',
|
||||||
|
assetFileNames: 'assets/[ext]/[name]-[hash].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Increase chunk size warning limit (default is 500kb)
|
||||||
|
chunkSizeWarningLimit: 1000,
|
||||||
|
// Enable source maps in dev only
|
||||||
|
sourcemap: isDev,
|
||||||
|
},
|
||||||
// Only configure server and HMR in development mode
|
// Only configure server and HMR in development mode
|
||||||
...(isDev && {
|
...(isDev && {
|
||||||
server: {
|
server: {
|
||||||
|
|||||||
Reference in New Issue
Block a user