-
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.js
More file actions
124 lines (106 loc) · 2.9 KB
/
vite.config.js
File metadata and controls
124 lines (106 loc) · 2.9 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import { fileURLToPath } from 'url';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
export default defineConfig({
plugins: [
react({
fastRefresh: true
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'@components': path.resolve(__dirname, 'src/components'),
'@pages': path.resolve(__dirname, 'src/pages'),
'@hooks': path.resolve(__dirname, 'src/hooks'),
'@utils': path.resolve(__dirname, 'src/utils'),
'@contexts': path.resolve(__dirname, 'src/contexts'),
'@constants': path.resolve(__dirname, 'src/constants')
},
extensions: ['.mjs', '.js', '.mts', '.ts', '.jsx', '.tsx', '.json']
},
server: {
port: 3000,
open: true,
strictPort: false,
hmr: {
overlay: true
}
},
preview: {
port: 4173,
open: true
},
build: {
outDir: 'dist',
sourcemap: false,
chunkSizeWarningLimit: 500,
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (
id.includes('react') ||
id.includes('react-dom') ||
id.includes('react-router-dom')
) {
return 'vendor-react';
}
if (id.includes('lucide-react') || id.includes('react-icons')) {
return 'vendor-icons';
}
if (id.includes('framer-motion')) {
return 'vendor-motion';
}
if (id.includes('react-dnd')) {
return 'vendor-dnd';
}
if (id.includes('react-window')) {
return 'vendor-virtualization';
}
}
},
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[hash].js',
assetFileNames: (assetInfo) => {
if (assetInfo.name && assetInfo.name.endsWith('.css')) {
return 'static/css/[name]-[hash][extname]';
}
return 'static/media/[name]-[hash][extname]';
}
}
},
minify: 'esbuild',
target: 'es2020',
cssCodeSplit: true,
// Inline only assets smaller than 4 KB (Vite default).
// Higher values would base64-encode SVG chess pieces into the JS bundle,
// increasing bundle size and disabling HTTP caching for those assets.
assetsInlineLimit: 4096
},
css: {
postcss: './postcss.config.js',
devSourcemap: true
},
optimizeDeps: {
include: [
'react',
'react-dom',
'react-router-dom',
'react-dnd',
'react-dnd-html5-backend',
'react-dnd-touch-backend',
'lucide-react',
'react-icons',
'react-window'
]
},
envPrefix: 'VITE_',
define: {
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'development'
)
}
});