vite.config.ts

432 B v1.0
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// 开发模式下前端跑在 5173,后端跑在 8787,通过代理转发 /api 请求
export default defineConfig({
  plugins: [react()],
  server: {
    port: 5173,
    proxy: {
      '/api': {
        target: 'http://localhost:8787',
        changeOrigin: false,
      },
    },
  },
  build: {
    outDir: 'dist',
    emptyOutDir: true,
  },
});