前端联调接口
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { defineConfig } from 'vite'
|
||||
import { defineConfig, loadEnv } from 'vite'
|
||||
import path from 'path'
|
||||
import vue from '@vitejs/plugin-vue'
|
||||
import Components from 'unplugin-vue-components/vite';
|
||||
@@ -6,38 +6,47 @@ import { VantResolver } from 'unplugin-vue-components/resolvers';
|
||||
|
||||
|
||||
// https://vitejs.dev/config/
|
||||
export default defineConfig({
|
||||
plugins: [vue(), Components({
|
||||
resolvers: [VantResolver()],
|
||||
}),],
|
||||
resolve: {
|
||||
// https://cn.vitejs.dev/config/#resolve-alias
|
||||
alias: {
|
||||
// 设置路径
|
||||
'~': path.resolve(__dirname, './'),
|
||||
// 设置别名
|
||||
'@': path.resolve(__dirname, './src')
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 17000,
|
||||
host: true,
|
||||
open: true,
|
||||
// proxy: {
|
||||
// // https://cn.vitejs.dev/config/#server-proxy
|
||||
// '/dev-api': {
|
||||
// target: VITE_APP_BASE_URL,
|
||||
// changeOrigin: true,
|
||||
// rewrite: (p) => p.replace(/^\/dev-api/, ''),
|
||||
// },
|
||||
export default defineConfig(({ mode, command }) => {
|
||||
const env = loadEnv(mode, process.cwd())
|
||||
const { VITE_APP_ENV, VITE_APP_BASE_URL} = env
|
||||
return {
|
||||
plugins: [vue(), Components({
|
||||
resolvers: [VantResolver()],
|
||||
}),],
|
||||
resolve: {
|
||||
// https://cn.vitejs.dev/config/#resolve-alias
|
||||
alias: {
|
||||
// 设置路径
|
||||
'~': path.resolve(__dirname, './'),
|
||||
// 设置别名
|
||||
'@': path.resolve(__dirname, './src')
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 17000,
|
||||
host: true,
|
||||
open: true,
|
||||
|
||||
|
||||
proxy: {
|
||||
// https://cn.vitejs.dev/config/#server-proxy
|
||||
'/dev-api': {
|
||||
target: VITE_APP_BASE_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-api/, ''),
|
||||
},
|
||||
|
||||
'/dev-ws': {
|
||||
target: VITE_APP_BASE_URL,
|
||||
changeOrigin: true,
|
||||
rewrite: (p) => p.replace(/^\/dev-ws/, ''),
|
||||
ws: true
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
// '/dev-ws': {
|
||||
// target: VITE_APP_BASE_URL,
|
||||
// changeOrigin: true,
|
||||
// rewrite: (p) => p.replace(/^\/dev-ws/, ''),
|
||||
// ws: true
|
||||
// }
|
||||
}
|
||||
|
||||
// }
|
||||
},
|
||||
})
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user