vite.config.ts 2.6 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 = "ga";
  6. if (process.argv.length > 3) {
  7. app = process.argv[process.argv.length - 1].trim();
  8. }
  9. const dev = false;
  10. export default defineConfig({
  11. define: {
  12. VITE_APP_APP: JSON.stringify(app),
  13. },
  14. base: "./",
  15. build: {
  16. outDir: `dist/${app}`,
  17. },
  18. resolve: {
  19. alias: [
  20. {
  21. find: "@",
  22. replacement: resolve(__dirname, "./src"),
  23. },
  24. ],
  25. },
  26. css: {
  27. preprocessorOptions: {
  28. scss: {
  29. additionalData: `@use "@/app/${app}/useStyle.scss" as *;`,
  30. },
  31. },
  32. },
  33. plugins: [
  34. vue(),
  35. ElementPlus({
  36. useSource: true,
  37. }),
  38. ],
  39. server: {
  40. port: 5173,
  41. proxy: {
  42. "/api": {
  43. target: dev
  44. ? "http://test-mix3d.4dkankan.com"
  45. : "https://mix3d.4dkankan.com",
  46. changeOrigin: true,
  47. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  48. },
  49. "/fusion": {
  50. target: dev
  51. ? "https://test-mix3d.4dkankan.com"
  52. : "https://mix3d.4dkankan.com",
  53. changeOrigin: true,
  54. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"),
  55. },
  56. "/dev-code": {
  57. // target: "https://localhost:7173/",
  58. target: dev
  59. ? "https://test-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(`^/swss`), ""),
  94. },
  95. },
  96. },
  97. });