vite.config.ts 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. import WindiCSS from 'vite-plugin-windicss'
  6. let app = "criminal";
  7. if (process.argv.length > 3) {
  8. app = process.argv[process.argv.length - 1].trim();
  9. }
  10. const dev = true;
  11. export default defineConfig({
  12. define: {
  13. VITE_APP_APP: JSON.stringify(app),
  14. },
  15. base: "./",
  16. build: {
  17. outDir: `dist/${app}`,
  18. },
  19. resolve: {
  20. alias: [
  21. {
  22. find: "@",
  23. replacement: resolve(__dirname, "./src"),
  24. },
  25. ],
  26. },
  27. css: {
  28. preprocessorOptions: {
  29. scss: {
  30. additionalData: `@use "@/app/${app}/useStyle.scss" as *;`,
  31. },
  32. },
  33. },
  34. plugins: [
  35. vue(),
  36. WindiCSS(),
  37. ElementPlus({
  38. useSource: true,
  39. }),
  40. ],
  41. server: {
  42. port: 5173,
  43. host: "0.0.0.0",
  44. proxy: {
  45. "/api": {
  46. target: dev ? "http://192.168.0.25" : "mix3d.4dkankan.com",
  47. changeOrigin: true,
  48. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  49. },
  50. "/fusion": {
  51. target: dev ? "http://192.168.0.25" : "mix3d.4dkankan.com",
  52. changeOrigin: true,
  53. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"),
  54. },
  55. "/dev-code": {
  56. // target: "https://localhost:7173/",
  57. target: dev
  58. ? "https://test-mix3d.4dkankan.com/code"
  59. : "https://mix3d.4dkankan.com/code",
  60. changeOrigin: true,
  61. secure: false,
  62. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  63. },
  64. "/swkk": {
  65. target: dev ? "https://test.4dkankan.com" : "https://www.4dkankan.com",
  66. changeOrigin: true,
  67. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  68. },
  69. "/service": {
  70. target: dev ? "http://192.168.0.25" : "https://www.4dkankan.com",
  71. changeOrigin: true,
  72. },
  73. "/swss": {
  74. target: dev
  75. ? "https://uat-laser.4dkankan.com/uat"
  76. : "https://laser.4dkankan.com",
  77. changeOrigin: true,
  78. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  79. },
  80. "/laser": {
  81. target: dev
  82. ? "https://uat-laser.4dkankan.com"
  83. : "https://laser.4dkankan.com",
  84. changeOrigin: true,
  85. rewrite: (path) => path.replace(new RegExp(`^/laser`), "/laser"),
  86. },
  87. "/fdkk": {
  88. target: dev
  89. ? "https://uat-laser.4dkankan.com/uat"
  90. : "https://laser.4dkankan.com",
  91. changeOrigin: true,
  92. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  93. },
  94. },
  95. },
  96. });