-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.js
More file actions
50 lines (49 loc) · 1.41 KB
/
vite.config.js
File metadata and controls
50 lines (49 loc) · 1.41 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
import { dirname, resolve } from 'node:path'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
const __dirname = dirname(fileURLToPath(import.meta.url))
export default defineConfig({
base: '/',
plugins: [react()],
build: {
chunkSizeWarningLimit: 1200,
rollupOptions: {
input: {
main: resolve(__dirname, 'index.html'),
nested: resolve(__dirname, 'nested/index.html'),
},
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
if (id.includes('react') || id.includes('react-dom')) return 'react-vendor';
return 'vendor';
}
}
}
}
},
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./src/setupTests.js'],
},
build: {
// Split large vendor bundles by package to reduce single huge chunk sizes
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
// create a chunk per top level package in node_modules
const parts = id.split('node_modules/')[1].split('/');
// scoped packages like @babel/core -> @babel
if (parts[0].startsWith('@')) return `${parts[0]}/${parts[1]}`;
return parts[0];
}
}
}
},
// keep warning threshold reasonable
chunkSizeWarningLimit: 600
}
})