vite.config.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. // 在这里继续添加更多页面
  21. },
  22. },
  23. outDir: `dist/${app}`,
  24. },
  25. resolve: {
  26. alias: [
  27. {
  28. find: "@",
  29. replacement: resolve(__dirname, "./src"),
  30. },
  31. ],
  32. },
  33. css: {
  34. preprocessorOptions: {
  35. scss: {
  36. additionalData: `@use "@/app/${app}/useStyle.scss" as *;`,
  37. },
  38. },
  39. },
  40. plugins: [
  41. vue(),
  42. ElementPlus({
  43. useSource: true,
  44. }),
  45. ],
  46. server: {
  47. port: 5173,
  48. host: "0.0.0.0",
  49. proxy: {
  50. "/api": {
  51. target: dev
  52. ? "http://test-mix3d.4dkankan.com"
  53. : "https://mix3d.4dkankan.com",
  54. changeOrigin: true,
  55. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  56. },
  57. "/fusion": {
  58. target: dev
  59. ? "https://test-mix3d.4dkankan.com"
  60. : "https://mix3d.4dkankan.com",
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"),
  63. },
  64. "/dev-code": {
  65. // target: "https://localhost:7173/",
  66. target: dev
  67. ? "https://test-mix3d.4dkankan.com/code"
  68. : "https://mix3d.4dkankan.com/code",
  69. changeOrigin: true,
  70. secure: false,
  71. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  72. },
  73. "/swkk": {
  74. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  75. changeOrigin: true,
  76. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  77. },
  78. "/service": {
  79. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  80. changeOrigin: true,
  81. },
  82. "/swss": {
  83. target: dev
  84. ? "https://uat-laser.4dkankan.com/uat"
  85. : "https://laser.4dkankan.com",
  86. changeOrigin: true,
  87. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  88. },
  89. "/laser": {
  90. target: dev
  91. ? "https://uat-laser.4dkankan.com"
  92. : "https://laser.4dkankan.com",
  93. changeOrigin: true,
  94. rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"),
  95. },
  96. "/fdkk": {
  97. target: dev
  98. ? "https://uat-laser.4dkankan.com/uat"
  99. : "https://laser.4dkankan.com",
  100. changeOrigin: true,
  101. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  102. },
  103. },
  104. },
  105. });