vite.config.js 492 B

123456789101112131415161718
  1. import { defineConfig } from 'vite'
  2. import react from '@vitejs/plugin-react'
  3. // 构建产物挂在 FastAPI 的 /app/ 下(base 必须对齐)。
  4. // dev 时把正式 API 请求代理到本地 uvicorn,省去跨域。
  5. const apiTarget = process.env.VITE_API_TARGET || 'http://127.0.0.1:8136'
  6. export default defineConfig({
  7. base: '/app/',
  8. plugins: [react()],
  9. build: { outDir: 'dist', emptyOutDir: true },
  10. server: {
  11. port: 5180,
  12. proxy: {
  13. '/api': apiTarget,
  14. },
  15. },
  16. })