import { defineConfig, loadEnv } from 'vite'; import react from '@vitejs/plugin-react'; import path from 'path'; // https://vite.dev/config/ export default defineConfig(({ mode }) => { // 加载环境变量 const env = loadEnv(mode, process.cwd(), ''); return { plugins: [react()], resolve: { alias: { '@': path.resolve(__dirname, 'src'), }, }, server: { proxy: { '^/api/': env.VITE_API_BASE_URL || 'http://localhost:8080/', }, host: '0.0.0.0', port: 3300, }, }; });