38 lines
864 B
TypeScript
38 lines
864 B
TypeScript
import { defineConfig } from 'vite'
|
|
import vue from '@vitejs/plugin-vue'
|
|
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
|
|
import { fileURLToPath, URL } from 'node:url'
|
|
import { createProxyMiddleware } from 'http-proxy-middleware'
|
|
|
|
|
|
// https://vitejs.dev/config/
|
|
export default defineConfig({
|
|
plugins: [
|
|
vue(),
|
|
vueSetupExtend(),
|
|
],
|
|
resolve: {
|
|
alias: {
|
|
'@': fileURLToPath(new URL('./src', import.meta.url))
|
|
}
|
|
},
|
|
server:{
|
|
// host:'192.168.28.44',
|
|
// host:'127.0.0.1',
|
|
// host: '192.168.28.32',
|
|
port: 8090,
|
|
open:true,
|
|
cors: true,
|
|
// proxy: {
|
|
// '/api': "192.168.28.44:8000"
|
|
// }
|
|
proxy: {
|
|
'/api': {
|
|
target: 'http://127.0.0.1:8000', // 目标 API 地址
|
|
changeOrigin: true, // 开启跨域
|
|
rewrite: path => path.replace('^/api/', '')
|
|
}
|
|
}
|
|
}
|
|
})
|