vite.config.ts 508 B

1234567891011121314151617181920
  1. import { defineConfig } from "vite";
  2. import react from "@vitejs/plugin-react";
  3. // BASE_PATH: 生产环境通过 nginx /ads/ 子路径代理时设为 "/ads/"
  4. // 本地开发默认 "/",也可通过环境变量覆盖:BASE_PATH=/ads/ npm run dev
  5. const BASE = process.env.BASE_PATH || "/";
  6. export default defineConfig({
  7. base: BASE,
  8. plugins: [react()],
  9. server: {
  10. port: 9527,
  11. proxy: {
  12. "/api": {
  13. target: "http://localhost:3001",
  14. changeOrigin: true,
  15. },
  16. },
  17. },
  18. });