Files
PolyHermes/frontend/vite.config.ts
T
WrBug 1216fc5ed5 feat: 添加前后端一体化 Docker 部署支持
- 创建根目录 Dockerfile,支持前后端一起部署到一个容器
- 添加 Nginx 配置,自动代理后端 API 和 WebSocket
- 创建启动脚本,同时启动后端和 Nginx
- 更新 docker-compose.yml 支持一体化部署
- 创建一体化部署脚本 deploy.sh
- 修复前端环境变量支持,默认使用相对路径
- 优化部署脚本:.env 文件不存在时创建后终止部署
- 更新部署文档,添加一体化部署说明
2025-12-03 03:08:53 +08:00

33 lines
769 B
TypeScript

import { defineConfig, loadEnv } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
// 加载环境变量
const env = loadEnv(mode, process.cwd(), '')
// 从环境变量获取后端地址,用于开发环境代理
// 如果未设置,使用默认值 localhost:8000
const API_URL = env.VITE_API_URL || 'http://localhost:8000'
const WS_URL = env.VITE_WS_URL || 'ws://localhost:8000'
return {
plugins: [react()],
server: {
port: 3000,
proxy: {
'/api': {
target: API_URL,
changeOrigin: true
},
'/ws': {
target: WS_URL,
ws: true,
changeOrigin: true
}
}
}
}
})