1
0
Files
coconut-leaf/frontend/vite.config.ts

38 lines
932 B
TypeScript
Raw Normal View History

2026-04-28 15:47:32 +08:00
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'
// https://vite.dev/config/
export default defineConfig({
plugins: [
vue(),
vueDevTools(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
// 项目基础路径(对应 Nginx 路由到的 /web 前缀)
base: '/web/',
server: {
port: 5173, // 开发服务器默认端口
open: '/web/', // 启动时自动打开 /web 路径
// 核心:代理配置(对应 Nginx 的 /api -> Go 服务)
proxy: {
// 精细控制路由,对齐生产环境
'^/api/(.*)$': {
target: 'http://127.0.0.1:8848',
changeOrigin: true,
// 路径重写/api/user -> /user
rewrite: (path) => path.replace(/^\/api\//, '/'),
}
},
2026-04-28 15:47:32 +08:00
})