| 12345678910111213141516171819202122232425 |
- import { defineConfig, loadEnv } from 'vite'
- import react from '@vitejs/plugin-react'
- // https://vite.dev/config/
- export default defineConfig(({ mode }) => {
- const env = loadEnv(mode, process.cwd(), '')
- return {
- plugins: [react()],
- server: {
- proxy: {
- // 开发环境下把 /api 同源代理到后端,避免浏览器 CORS 预检
- '/api': {
- target: env.VITE_DEV_API_TARGET || 'http://127.0.0.1:3000',
- changeOrigin: true,
- },
- },
- },
- test: {
- environment: 'jsdom',
- setupFiles: './src/test/setup.ts',
- exclude: ['**/.worktrees/**', '**/node_modules/**', '**/dist/**'],
- },
- }
- })
|