vite.config.ts 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. import ElementPlus from "unplugin-element-plus/vite";
  5. let app = "fire";
  6. if (process.argv.length > 3) {
  7. app = process.argv[process.argv.length - 1].trim();
  8. }
  9. const dev = true;
  10. export default defineConfig({
  11. define: {
  12. VITE_APP_APP: JSON.stringify(app),
  13. },
  14. base: "./",
  15. build: {
  16. rollupOptions: {
  17. input: {
  18. index: resolve(__dirname, "index.html"),
  19. map: resolve(__dirname, "map.html"),
  20. mirror: resolve(__dirname, "mirror.html"),
  21. // 在这里继续添加更多页面
  22. },
  23. },
  24. outDir: `dist/${app}`,
  25. },
  26. resolve: {
  27. alias: [
  28. {
  29. find: "@",
  30. replacement: resolve(__dirname, "./src"),
  31. },
  32. ],
  33. },
  34. plugins: [
  35. vue(),
  36. ElementPlus({
  37. useSource: true,
  38. }),
  39. ],
  40. server: {
  41. port: 5173,
  42. host: "0.0.0.0",
  43. proxy: {
  44. "/api": {
  45. target: dev ? "http://xj-mix3d.4dkankan.com" : "mix3d.4dkankan.com",
  46. changeOrigin: true,
  47. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  48. },
  49. "/fusion-xj": {
  50. target: dev ? "https://xj-mix3d.4dkankan.com" : "mix3d.4dkankan.com",
  51. changeOrigin: true,
  52. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion-xj"),
  53. },
  54. "/dev-code": {
  55. // target: "https://localhost:7173/",
  56. target: dev
  57. ? "https://xj-mix3d.4dkankan.com/code"
  58. : "https://mix3d.4dkankan.com/code",
  59. changeOrigin: true,
  60. secure: false,
  61. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  62. },
  63. "/swkk": {
  64. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  65. changeOrigin: true,
  66. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  67. },
  68. "/service": {
  69. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  70. changeOrigin: true,
  71. },
  72. "/swss": {
  73. target: dev
  74. ? "https://uat-laser.4dkankan.com/uat"
  75. : "https://laser.4dkankan.com",
  76. changeOrigin: true,
  77. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  78. },
  79. "/laser": {
  80. target: dev
  81. ? "https://uat-laser.4dkankan.com"
  82. : "https://laser.4dkankan.com",
  83. changeOrigin: true,
  84. rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"),
  85. },
  86. "/fdkk": {
  87. target: dev
  88. ? "https://uat-laser.4dkankan.com/uat"
  89. : "https://laser.4dkankan.com",
  90. changeOrigin: true,
  91. rewrite: (path) => path.replace(new RegExp(`^/fdkk`), "/fdkk"),
  92. },
  93. },
  94. },
  95. });