-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
91 lines (85 loc) · 2.05 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
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
import path from 'path';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react-swc';
import checker from 'vite-plugin-checker';
import svgr from 'vite-plugin-svgr';
import { nodePolyfills } from 'vite-plugin-node-polyfills';
export default ({ mode }) => {
const env = loadEnv(mode, process.cwd());
const target = env.VITE_TARGET_URL;
console.log(env.VITE_ENV_NAME);
return defineConfig({
esbuild: {
supported: {
'top-level-await': true, //browsers can handle top-level-await features
},
},
optimizeDeps: {
exclude: ['js-big-decimal', 'fsevents'],
include: ['@chainsafe/bls-keystore'],
esbuildOptions: {
target: 'esnext',
// Node.js global to browser globalThis
define: {
global: 'globalThis',
},
},
},
plugins: [
svgr(),
react(),
checker({
typescript: true,
eslint: {
lintCommand: 'eslint "./src/**/*.{js,jsx,ts,tsx}"',
},
overlay: {
initialIsOpen: false,
},
}),
nodePolyfills({
include: ['path', 'stream', 'util', 'os', 'crypto', 'fs', 'zlib', 'vm'],
// exclude: ['http'],
globals: {
Buffer: true,
global: true,
process: true,
},
overrides: {
fs: 'memfs',
},
protocolImports: true,
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
build: {
target: 'esnext',
// sourcemap: env.VITE_ENV_NAME === 'development' ? 'inline' : false,
// sourcemap: false,
},
server: {
port: 8088,
proxy: {
'/api': {
target: target,
secure: false,
changeOrigin: true,
// pathRewrite: { '^/api': '' },
},
'/server': {
target: target,
secure: false,
changeOrigin: true,
// pathRewrite: { '^/api': '' },
},
},
},
preview: {
port: 8088,
},
});
};