根目录下vite.config.js

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
const path = require('path')

export default {
proxy: {
'/api': {
target: 'http://*.*.*.*:*',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
}
},
alias: {
'/@/': path.resolve(__dirname, './src'),
"/@assets/": path.resolve(__dirname, "./src/assets"),
"/@request/": path.resolve(__dirname, "./src/framework/request"),
"/@api/": path.resolve(__dirname, "./src/framework/api"),
"/@utils/": path.resolve(__dirname, "./src/framework/utils"),
"/@router/": path.resolve(__dirname, "./src/framework/router"),
},
}