vite.config.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. api: 'modern-compiler',// or "modern"
  37. additionalData: `@use "@/app/${app}/useStyle.scss" as *;`,
  38. },
  39. },
  40. },
  41. plugins: [
  42. vue(),
  43. ElementPlus({
  44. useSource: true,
  45. }),
  46. ],
  47. server: {
  48. port: 5173,
  49. host: "0.0.0.0",
  50. proxy: {
  51. "/api": {
  52. target: dev
  53. ? "http://test-mix3d.4dkankan.com"
  54. : "https://mix3d.4dkankan.com",
  55. changeOrigin: true,
  56. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  57. },
  58. "/fusion": {
  59. target: dev
  60. ? "https://test-mix3d.4dkankan.com"
  61. : "https://mix3d.4dkankan.com",
  62. changeOrigin: true,
  63. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"),
  64. },
  65. "/dev-code": {
  66. // target: "https://localhost:7173/",
  67. target: dev
  68. ? "https://test-mix3d.4dkankan.com/code"
  69. : "https://mix3d.4dkankan.com/code",
  70. changeOrigin: true,
  71. secure: false,
  72. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  73. },
  74. "/swkk": {
  75. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  76. changeOrigin: true,
  77. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  78. },
  79. "/service": {
  80. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  81. changeOrigin: true,
  82. },
  83. "/swss": {
  84. target: dev
  85. ? "https://uat-laser.4dkankan.com/uat"
  86. : "https://laser.4dkankan.com",
  87. changeOrigin: true,
  88. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  89. },
  90. "/laser": {
  91. target: dev
  92. ? "https://uat-laser.4dkankan.com"
  93. : "https://laser.4dkankan.com",
  94. changeOrigin: true,
  95. rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"),
  96. },
  97. "/fdkk": {
  98. target: dev
  99. ? "https://uat-laser.4dkankan.com/uat"
  100. : "https://laser.4dkankan.com",
  101. changeOrigin: true,
  102. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  103. },
  104. },
  105. },
  106. });