vite.config.ts
1.26 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
import react from '@vitejs/plugin-react';
import { fileURLToPath, URL } from 'node:url';
import { loadEnv } from 'vite';
import { defineConfig } from 'vitest/config';
// const DEFAULT_PROXY_TARGET = 'http://192.168.1.191:8000';
const DEFAULT_PROXY_TARGET = 'http://agent-admin.test.glsx.com.cn/backend';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '');
const proxyTarget = env.VITE_API_PROXY_TARGET || DEFAULT_PROXY_TARGET;
return {
plugins: [react()],
resolve: {
alias: {
'@gl/business-components': fileURLToPath(new URL('../../../packages/business-components/src/index.ts', import.meta.url)),
react: fileURLToPath(new URL('./node_modules/react', import.meta.url)),
'tdesign-icons-react': fileURLToPath(new URL('./node_modules/tdesign-icons-react', import.meta.url)),
'tdesign-react': fileURLToPath(new URL('./node_modules/tdesign-react', import.meta.url)),
},
},
server: {
host: '0.0.0.0',
proxy: {
'/api': {
target: proxyTarget,
changeOrigin: true,
},
},
},
preview: {
host: '0.0.0.0',
},
test: {
environment: 'jsdom',
globals: true,
setupFiles: './src/test/setup.ts',
},
};
});