Files
xieyi-weixin-/admin-web/apps/web-antd/vite.config.ts
T
2026-09-28 10:02:07 +08:00

29 lines
1.0 KiB
TypeScript

import { defineConfig } from '@vben/vite-config';
export default defineConfig(async () => {
return {
application: {},
vite: {
resolve: {
// Workspace packages must share the same injection keys and store instance.
dedupe: ['vue', 'vue-router', 'pinia'],
},
server: {
proxy: {
// 前端统一请求 /api/*,代理到 admin_api.py 的 /api/v2/*。
// 走代理而不是直连,是为了开发态和生产态同源、没有 CORS 差异——
// 生产环境前端是静态文件,由同一个 Nginx 反代到后端。
'/api': {
changeOrigin: true,
rewrite: (path) => path.replace(/^\/api/, '/api/v2'),
// 端口可用环境变量覆盖:本机同时跑多套后端时(比如拿一次性的库
// 验证前端,不碰生产库)不用改代码。
target: process.env.VITE_API_TARGET || 'http://127.0.0.1:8766',
ws: false,
},
},
},
},
};
});