import { defineConfig } from 'vite'; import react from '@vitejs/plugin-react'; import { fileURLToPath, URL } from 'node:url'; // 让 import 路径与项目文件夹名(bj_power_dashboard)对齐 const dashboardAlias = '@bj_power_dashboard'; export default defineConfig({ plugins: [react()], resolve: { alias: { [dashboardAlias]: fileURLToPath(new URL('./src', import.meta.url)), }, }, server: { port: 5173, // 大屏项目:启动后自动拉起浏览器,避免每次手动输地址 open: true, host: true, proxy: { // 开发环境代理到 MES(实际端口 8888,早期写 8000 导致连不上) '/api': { target: process.env.VITE_MES_BASE_URL || 'http://127.0.0.1:8888', changeOrigin: true, }, }, }, });