vite.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { defineConfig } from 'vite'
  2. import vue from '@vitejs/plugin-vue'
  3. import { viteStaticCopy } from 'vite-plugin-static-copy'
  4. import { fileURLToPath } from "node:url";
  5. // https://vitejs.dev/config/
  6. export default defineConfig({
  7. base: '/',
  8. plugins: [
  9. vue(),
  10. ],
  11. server: {
  12. port: 3000,
  13. proxy: {
  14. '/api': {
  15. target: 'http://localhost:5001',
  16. changeOrigin: true
  17. },
  18. '/ws': {
  19. target: 'ws://localhost:5001',
  20. ws: true,
  21. changeOrigin: true
  22. },
  23. // Socket.IO 走 /socket.io/(polling + websocket 升级),本地 dev 必须代理,否则握手命中 SPA 回退
  24. '/socket.io': {
  25. target: 'http://localhost:5001',
  26. ws: true,
  27. changeOrigin: true
  28. }
  29. }
  30. },
  31. resolve: {
  32. alias: {
  33. "@": fileURLToPath(new URL("./src", import.meta.url)),
  34. },
  35. extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  36. },
  37. css: {
  38. preprocessorOptions: {
  39. scss: {
  40. // additionalData: '@import "@/assets/scss/global.scss";',
  41. },
  42. },
  43. }
  44. })