vite.config.js 1014 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { fileURLToPath, URL } from 'node:url'
  4. export default defineConfig({
  5. plugins: [vue()],
  6. resolve: {
  7. alias: {
  8. '@': fileURLToPath(new URL('./src', import.meta.url))
  9. }
  10. },
  11. define: {
  12. // 修复 SockJS 客户端在 Vite 环境下的兼容性问题
  13. global: 'globalThis'
  14. },
  15. server: {
  16. port: 5173,
  17. host: true,
  18. proxy: {
  19. // 使用 /dev-api 前缀,与 RobotSpineWeb 保持一致
  20. '/dev-api': {
  21. target: 'http://192.168.0.30:8080',
  22. //target: 'http://localhost:8080',
  23. changeOrigin: true,
  24. rewrite: (path) => path.replace(/^\/dev-api/, '')
  25. },
  26. // WebSocket 连接代理
  27. '/ws': {
  28. target: 'http://192.168.0.30:8080',
  29. //target: 'http://localhost:8080',
  30. changeOrigin: true,
  31. ws: true
  32. }
  33. }
  34. },
  35. build: {
  36. outDir: 'dist',
  37. assetsDir: 'assets',
  38. sourcemap: false,
  39. chunkSizeWarningLimit: 1000
  40. }
  41. })