vite.config.ts 600 B

123456789101112131415161718192021222324
  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. "/q": {
  17. target: "http://localhost:3001",
  18. changeOrigin: true,
  19. },
  20. },
  21. },
  22. });