-
Notifications
You must be signed in to change notification settings - Fork 5
/
vite.config.js
42 lines (38 loc) · 937 Bytes
/
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
import { fileURLToPath, URL } from 'node:url'
import {defineConfig, loadEnv} from 'vite'
import vue from '@vitejs/plugin-vue'
export default ({mode})=>{
const env = loadEnv(mode,process.cwd())
const baseUrl = env.VITE_API
const baseUrlWs = env.VITE_WEBSOCKET
console.log(env)
return defineConfig({
envPrefix:["VITE_"],
plugins: [vue()],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
server:{
host:"127.0.0.1",
port:5173,
proxy:{
"/uploads":{
target: baseUrl
},
"/wsUrl":{
target: baseUrlWs, //这里是后台ws访问地址
changeOrigin: true, //允许跨域设置
ws: true, //websocket代理设置
rewrite: (path)=> path.replace(/^\/wsUrl/,""), //拦截路径去除
},
"/api":{
target: baseUrl
}
}
}
})
}
// https://vitejs.dev/config/
// 重定向到代理地址