-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
59 lines (57 loc) · 2 KB
/
vite.config.js
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
import eslintPlugin from 'vite-plugin-eslint';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), eslintPlugin()],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'), // src 路径
'~': path.resolve(__dirname, 'src/pages'), // src/pages 路径
},
},
css: {
preprocessorOptions: {
scss: {
additionalData: '@import "@/styles/variables.scss";',
},
},
},
server: {
port: 5173,
// 开发环境启动的端口
proxy: {
'/api': {
// 当遇到 /api 路径时,将其转换成 target 的值,这里我们为了测试,写了github的请求地址
target: 'https://api.github.com',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, ''), // 将 /api 重写为空
},
'/dragonball': {
// 当遇到 /api 路径时,将其转换成 target 的值,这里我们为了测试,写了github的请求地址
// target: 'http://10.59.116.235:8088',
target: 'http://10.57.237.13:8000',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dragonball/, ''), // 将 /api 重写为空
},
'/dragonclaw': {
// 当遇到 /api 路径时,将其转换成 target 的值,这里我们为了测试,写了github的请求地址
// target: 'http://10.59.192.191:8088',
target: 'http://10.57.237.13:8009',
changeOrigin: true,
rewrite: (path) => path.replace(/^\/dragonclaw/, ''), // 将 /api 重写为空
// configure: (proxy) => {
// proxy.on('proxyReq', (proxyReq, req, res) => {
// res.setHeader('x-clientId', `dragon-ball`);
// res.setHeader(
// 'x-secretKey',
// `b31fe76e56556443622fae8cb9e4680d0b76500405bdf70d11916c21ef5a2d78`
// );
// proxyReq.pipe(res);
// });
// },
},
},
},
});