-
Notifications
You must be signed in to change notification settings - Fork 1.3k
/
Copy pathvite.config.ts
86 lines (82 loc) · 1.92 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
import {
defineConfig,
loadEnv,
UserConfigExport,
splitVendorChunkPlugin,
} from 'vite';
import react from '@vitejs/plugin-react-swc';
import tsconfigPaths from 'vite-tsconfig-paths';
import { ViteEjsPlugin } from 'vite-plugin-ejs';
export default defineConfig(({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) };
const defaultConfig: UserConfigExport = {
plugins: [
react(),
tsconfigPaths(),
splitVendorChunkPlugin(),
ViteEjsPlugin({
PUBLIC_PATH: mode !== 'development' ? 'PUBLIC-PATH-VARIABLE' : '',
}),
],
server: {
port: 3000,
},
build: {
outDir: 'build',
rollupOptions: {
output: {
manualChunks: {
ace: ['ace-builds', 'react-ace'],
},
},
},
},
experimental: {
renderBuiltUrl(
filename: string,
{
hostType,
}: {
hostId: string;
hostType: 'js' | 'css' | 'html';
type: 'asset' | 'public';
}
) {
if (hostType === 'js') {
return {
runtime: `window.__assetsPathBuilder(${JSON.stringify(filename)})`,
};
}
return filename;
},
},
define: {
'process.env.NODE_ENV': `"${mode}"`,
'process.env.VITE_TAG': `"${process.env.VITE_TAG}"`,
'process.env.VITE_COMMIT': `"${process.env.VITE_COMMIT}"`,
},
};
const proxy = process.env.VITE_DEV_PROXY;
if (mode === 'development' && proxy) {
return {
...defaultConfig,
server: {
...defaultConfig.server,
open: true,
proxy: {
'/api': {
target: proxy,
changeOrigin: true,
secure: false,
},
'/actuator/info': {
target: proxy,
changeOrigin: true,
secure: false,
},
},
},
};
}
return defaultConfig;
});