-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
89 lines (88 loc) · 2.46 KB
/
vite.config.ts
File metadata and controls
89 lines (88 loc) · 2.46 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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { visualizer } from 'rollup-plugin-visualizer';
// https://vite.dev/config/
export default defineConfig(({ isSsrBuild }) => ({
server: {
watch: {
ignored: ['**/.claude/**', '**/untracked/**', '**/var/**'],
},
},
plugins: [
react(),
// Skip visualizer for SSR builds — only needed for client bundle analysis
...(!isSsrBuild
? [
visualizer({
filename: 'var/bundle-analysis.html',
open: false,
gzipSize: true,
brotliSize: true,
}),
]
: []),
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src'),
},
},
build: {
outDir: 'dist',
sourcemap: false,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true,
pure_funcs: ['console.log', 'console.info', 'console.debug'],
passes: 2,
},
mangle: {
safari10: true,
},
},
reportCompressedSize: false,
chunkSizeWarningLimit: 1000,
rollupOptions: {
output: {
// manualChunks only applies to the client build
...(isSsrBuild
? {}
: {
manualChunks: (id: string) => {
if (
id.includes('node_modules/react/') ||
id.includes('node_modules/react-dom/') ||
id.includes('node_modules/scheduler/')
) {
return 'react-core';
}
if (
id.includes('node_modules/react-router-dom/') ||
id.includes('node_modules/react-router/') ||
id.includes('node_modules/@remix-run/')
) {
return 'react-router';
}
if (id.includes('node_modules/highlight.js/')) {
return 'highlight-js';
}
if (
id.includes('node_modules/react-hook-form/') ||
id.includes('node_modules/zod/') ||
id.includes('node_modules/@hookform/')
) {
return 'ui-libs';
}
if (id.includes('node_modules/')) {
return 'vendor';
}
},
chunkFileNames: 'assets/[name]-[hash].js',
}),
},
},
},
}));