vite.config.ts 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. secure: false,
  46. target: dev ? "https://192.168.0.25" : "mix3d.4dkankan.com",
  47. changeOrigin: true,
  48. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  49. },
  50. "/fusion-xj": {
  51. secure: false,
  52. target: dev ? "https://192.168.0.25" : "mix3d.4dkankan.com",
  53. changeOrigin: true,
  54. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion-xj"),
  55. },
  56. "/dev-code": {
  57. // target: "https://localhost:7173/",
  58. target: dev
  59. ? "https://xj-mix3d.4dkankan.com/code"
  60. : "https://mix3d.4dkankan.com/code",
  61. changeOrigin: true,
  62. secure: false,
  63. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  64. },
  65. "/swkk": {
  66. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  67. changeOrigin: true,
  68. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  69. },
  70. "/service": {
  71. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  72. changeOrigin: true,
  73. },
  74. "/swss": {
  75. target: dev
  76. ? "https://uat-laser.4dkankan.com/uat"
  77. : "https://laser.4dkankan.com",
  78. changeOrigin: true,
  79. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  80. },
  81. "/laser": {
  82. target: dev
  83. ? "https://uat-laser.4dkankan.com"
  84. : "https://laser.4dkankan.com",
  85. changeOrigin: true,
  86. rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"),
  87. },
  88. "/fdkk": {
  89. target: dev
  90. ? "https://uat-laser.4dkankan.com/uat"
  91. : "https://laser.4dkankan.com",
  92. changeOrigin: true,
  93. rewrite: (path) => path.replace(new RegExp(`^/fdkk`), "/fdkk"),
  94. },
  95. },
  96. },
  97. });