import path from 'node:path' import { fileURLToPath } from 'node:url' import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' const rootDir = path.dirname(fileURLToPath(import.meta.url)) const frontendPort = Number(process.env.HXOPS_FRONTEND_PORT || '8881') const apiProxyTarget = process.env.HXOPS_API_PROXY_TARGET || 'http://127.0.0.1:5052' // https://vite.dev/config/ export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': path.resolve(rootDir, 'src'), }, }, server: { port: frontendPort, // 默认 8881,允许本地通过环境变量覆盖,避免与其它仓库冲突 strictPort: true, // 端口被占用时直接失败,由 start_local.ps1 先释放旧进程 allowedHosts: ['hx.benl.cn'], proxy: { '/api': { target: apiProxyTarget, changeOrigin: true } } } })