import { defineConfig, loadEnv } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' // https://vite.dev/config/ export default defineConfig(({ mode }) => { // 加载环境变量 const env = loadEnv(mode, process.cwd()) const base = env.VITE_BASE || '/' return { // 部署路径前缀 base, plugins: [vue()], resolve: { alias: { '@': path.resolve(__dirname, 'src') } }, server: { port: 3000, proxy: { // 所有 /fund/ 请求代理到网关,去掉 /fund 前缀 '/fund/': { target: 'http://localhost:8000', changeOrigin: true, rewrite: (path) => path.replace(/^\/fund/, '') } } } } })