-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
96 lines (95 loc) · 2.66 KB
/
Copy pathvite.config.ts
File metadata and controls
96 lines (95 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import { TanStackRouterVite } from '@tanstack/router-plugin/vite'
import tailwindcss from '@tailwindcss/vite'
import path from 'path'
export default defineConfig({
plugins: [
TanStackRouterVite({ autoCodeSplitting: true }),
tailwindcss(),
react()
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
target: 'es2020',
minify: 'terser',
cssMinify: true,
rollupOptions: {
output: {
manualChunks: (id) => {
// Group heavy/shared node_modules into cacheable chunks.
// Unmatched node_modules are left to Rollup's default splitter.
if (id.includes('node_modules')) {
if (id.includes('/react/') || id.includes('/react-dom/') || id.includes('/scheduler/') || id.includes('/use-sync-external-store/')) {
return 'vendor';
}
if (id.includes('/@tanstack/react-router/')) {
return 'router';
}
if (id.includes('/@tanstack/react-query/')) {
return 'query';
}
if (id.includes('/recharts/') || id.includes('/d3-')) {
return 'charts';
}
if (id.includes('/lucide-react/')) {
return 'icons';
}
if (id.includes('/jspdf/') || id.includes('/jspdf-autotable/') || id.includes('/dompurify/')) {
return 'pdf';
}
if (id.includes('/html2canvas/')) {
return 'html2canvas';
}
if (id.includes('date-fns')) {
return 'date';
}
if (id.includes('zustand')) {
return 'state';
}
if (id.includes('react-hot-toast')) {
return 'toast';
}
}
},
// Ensure consistent chunk naming for better caching
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
assetFileNames: 'assets/[name]-[hash][extname]',
},
},
chunkSizeWarningLimit: 500,
sourcemap: false,
// Enable CSS code splitting
cssCodeSplit: true,
// Report bundle size
reportCompressedSize: true,
},
optimizeDeps: {
include: [
'react',
'react-dom',
'@tanstack/react-router',
'recharts',
'@tanstack/react-query',
'lucide-react',
'zustand',
'date-fns',
],
},
// Performance optimizations for Netlify
server: {
headers: {
'Cache-Control': 'no-cache',
},
},
preview: {
headers: {
'Cache-Control': 'no-cache',
},
},
})