import { defineConfig } from "vite"; import vue from "@vitejs/plugin-vue"; import { resolve } from "path"; const pathResolve = (dir: string) => { return resolve(process.cwd(), ".", dir); }; // https://vitejs.dev/config/ export default defineConfig({ resolve: { alias: [ { find: "@", replacement: pathResolve("src"), }, ], dedupe: ["vue"], }, plugins: [vue()], server: { proxy: { // 代理配置 '/api': { // target: 'http://192.168.1.104:8083', // 目标服务器 target: 'http://192.168.99.49:8083', // 目标服务器 changeOrigin: true, // 需要虚拟主机站点 rewrite: (path) => path.replace(/^\/api/, '/api/') // 重写 API 请求 } } } });