-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathvite.config.ts
More file actions
55 lines (54 loc) · 1.66 KB
/
vite.config.ts
File metadata and controls
55 lines (54 loc) · 1.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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
export default defineConfig({
plugins: [react()],
base: './',
resolve: { // solves the problem with link modules and different react instances
dedupe: ['react', 'react-dom']
},
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
},
build: {
outDir: 'build',
assetsDir: 'static',
sourcemap: true,
cssCodeSplit: true,
minify: true,
chunkSizeWarningLimit: 3000,
rollupOptions: {
output: {
entryFileNames: (chunkInfo) => {
if (chunkInfo.name === 'index') { // change index-hash.js to main.hash.js
return 'static/js/main.[hash].js';
}
return 'static/js/[name].[hash].js';
},
chunkFileNames: (chunkInfo) => {
if (chunkInfo.name.includes('rolldown-runtime')) {
return 'static/js/vendor-runtime.[hash].js';
}
return 'static/js/[name].[hash].js';
},
assetFileNames: (assetInfo) => {
const name = assetInfo.names?.[0] ?? '';
const ext = name.split('.').pop();
if (ext === 'css') {
return 'static/css/[name]-[hash][extname]';
}
return 'static/media/[name]-[hash][extname]';
},
manualChunks: (id: string) => {
if (id.includes('node_modules')) {
return 'vendor'; // avoid extra auto.esm.*.js and pack all modules into vendor
}
}
// default generation
// manualChunks: {
// vendor: ['react', 'react-dom']
// }
}
}
}
});