vite.config.ts 2.7 KB

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