import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { fileURLToPath, URL } from 'node:url' export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, define: { // 修复 SockJS 客户端在 Vite 环境下的兼容性问题 global: 'globalThis' }, server: { port: 5173, host: true, proxy: { // 使用 /dev-api 前缀,与 RobotSpineWeb 保持一致 '/dev-api': { target: 'http://192.168.0.30:8080', //target: 'http://localhost:8080', changeOrigin: true, rewrite: (path) => path.replace(/^\/dev-api/, '') }, // WebSocket 连接代理 '/ws': { target: 'http://192.168.0.30:8080', //target: 'http://localhost:8080', changeOrigin: true, ws: true } } }, build: { outDir: 'dist', assetsDir: 'assets', sourcemap: false, chunkSizeWarningLimit: 1000 } })