forked from sibvisions/reactUI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
51 lines (50 loc) · 1.52 KB
/
Copy pathvite.config.ts
File metadata and controls
51 lines (50 loc) · 1.52 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
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
alias: {
react: path.resolve(__dirname, 'node_modules/react'),
'react-dom': path.resolve(__dirname, 'node_modules/react-dom')
}
},
define: {
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'production')
},
build: {
outDir: 'build',
assetsDir: 'static',
sourcemap: true,
cssCodeSplit: true,
minify: 'esbuild',
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: 'static/js/[name].[hash].js',
assetFileNames: (assetInfo) => {
const ext = assetInfo.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']
// }
}
}
}
});