vite.config.ts 2.5 KB

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