-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
34 lines (31 loc) · 1023 Bytes
/
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
import reactPlugin from '@vitejs/plugin-react';
import { type ConfigEnv, defineConfig, loadEnv } from 'vite';
import tsconfigPathsPlugin from 'vite-tsconfig-paths';
const config = ({ mode }: ConfigEnv): ReturnType<typeof defineConfig> => {
const {
VITE_APP_PROXY_SERVER_URL,
VITE_APP_API_ORIGIN_URL,
VITE_APP_DEVELOPMENT_PORT,
VITE_APP_SOCKET_PATH,
} = loadEnv(mode, process.cwd());
return defineConfig({
build: {
outDir: 'build',
},
plugins: [tsconfigPathsPlugin(), reactPlugin()],
server: {
port: Number(VITE_APP_DEVELOPMENT_PORT),
proxy: {
[VITE_APP_API_ORIGIN_URL]: {
target: VITE_APP_PROXY_SERVER_URL,
changeOrigin: true,
},
[VITE_APP_SOCKET_PATH]: {
target: VITE_APP_PROXY_SERVER_URL,
ws: true,
},
},
},
});
};
export default config;