-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
67 lines (66 loc) · 1.73 KB
/
vite.config.ts
File metadata and controls
67 lines (66 loc) · 1.73 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
// https://vite.dev/config/
// v1.0.2: Bundle Optimization for Offline-First Performance
export default defineConfig({
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin']
}
})
],
server: {
port: 5173
},
build: {
outDir: 'dist',
sourcemap: false, // [+] Production builds: no sourcemaps (save 20-30%)
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
dead_code: true
},
mangle: true
},
rollupOptions: {
output: {
// [+] Code splitting: separate vendors & core
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
'd3-vendor': ['d3'],
'ui-core': [
'src/design-system',
'src/components'
]
},
// [+] Minimize chunk names for smaller filenames
entryFileNames: 'js/[name]-[hash].js',
chunkFileNames: 'js/[name]-[hash].js',
assetFileNames: ({ name }) => {
if (name.endsWith('.css')) {
return 'css/[name]-[hash][extname]';
}
return 'assets/[name]-[hash][extname]';
}
}
},
// [+] Optimize chunk size thresholds
chunkSizeWarningLimit: 600,
reportCompressedSize: true,
// [+] CSS code splitting
cssCodeSplit: true,
// [+] Module preload
modulePreload: {
polyfill: false // Already in modern browsers
}
},
// [+] Optimize dependencies
optimizeDeps: {
include: ['react', 'react-dom', 'd3'],
exclude: ['pyodide'] // Lazy-load heavy modules
}
});