forked from NnsDAO-tech/FE-template-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
62 lines (60 loc) · 1.43 KB
/
vite.config.ts
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
import react from '@vitejs/plugin-react';
import { visualizer } from 'rollup-plugin-visualizer';
import { defineConfig } from 'vite';
export default defineConfig(({ command, mode }) => {
console.log('command,mode', command, mode);
return {
publicDir: 'src/public',
envDir: 'env',
envPrefix: ['VITE_', 'DEV_', 'xxx_'],
plugins: ((plugin) => {
if (mode === 'production') {
plugin.push(
// @ts-ignore
visualizer({
open: true,
gzipSize: true,
brotliSize: true
})
);
}
return plugin;
})([react()]),
build: {
outDir: 'dist',
cssCodeSplit: true,
chunkSizeWarningLimit: 500,
minify: 'terser',
terserOptions: {
compress: {
drop_console: true,
drop_debugger: true
}
},
assetsDir: 'assets',
rollupOptions: {
output: {
chunkFileNames: 'assets/js/[name]-[hash].js',
entryFileNames: 'assets/js/[name]-[hash].js',
assetFileNames: 'assets/[ext]/[name]-[hash][extname]'
}
}
},
server: {
fs: {
strict: false
},
proxy: {
'/api/v2': {
target: 'https://ic0.app',
changeOrigin: true,
rewrite: (path) => path.replace(/^api\//, '/api/v2/canister')
}
}
},
define: {
// dfx rely on this
'process.env': {}
}
};
});