-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
55 lines (52 loc) · 1.51 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
// vite.config.ts
import UnoCSS from 'unocss/vite';
import { defineConfig, loadEnv } from 'vite';
import react from '@vitejs/plugin-react';
import path from 'path';
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd());
return {
base: './',
plugins: [
react(),
UnoCSS({
configFile: './uno.config.ts',
}),
],
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
'./cptable': 'cptable', // 指向已安装的模块
},
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
server: {
// port: 8082,
proxy: {
'/api': {
target: env.VITE_BASE_URL,
changeOrigin: true,
rewrite: (path) => path,
},
},
host: '0.0.0.0',
hmr: true,
},
build: {
sourcemap: mode === 'development',
},
};
});
// $r2}#TqJn$5dQYB]^0(J
// rewrite: (path) => path,
// .replace(/^\/api/, ''),
// bypass: (req, res, options) => {
// const proxyUrl =
// new URL(
// options?.rewrite(req.url) || '',
// options.target as string,
// ).href || '';
// console.log(proxyUrl, 'xxx');
// req.headers['x-req-proxyUrl'] = proxyUrl;
// res.setHeader('x-res-proxyUrl', proxyUrl);
// },