2026-02-02 08:54:11 +08:00
|
|
|
import { defineConfig } from 'vite'
|
|
|
|
|
import react from '@vitejs/plugin-react'
|
|
|
|
|
import path from "path"
|
|
|
|
|
import tailwindcss from "@tailwindcss/vite"
|
|
|
|
|
// https://vite.dev/config/
|
|
|
|
|
export default defineConfig({
|
2026-02-02 16:34:10 +08:00
|
|
|
server: {
|
|
|
|
|
proxy: {
|
|
|
|
|
// 1. 匹配所有以 /api 开头的请求
|
|
|
|
|
'/api': {
|
|
|
|
|
target: 'http://localhost', // 你的 Java 后端地址
|
|
|
|
|
changeOrigin: true, // 允许跨域
|
|
|
|
|
// 2. 路径重写:如果后端接口没有 /api 前缀,就把它删掉
|
|
|
|
|
rewrite: (path) => path.replace(/^\/api/, '')
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
2026-02-02 08:54:11 +08:00
|
|
|
plugins: [
|
|
|
|
|
tailwindcss(),
|
|
|
|
|
react({
|
|
|
|
|
babel: {
|
|
|
|
|
plugins: [['babel-plugin-react-compiler']],
|
|
|
|
|
},
|
|
|
|
|
}),
|
|
|
|
|
],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
})
|