vite.config.ts 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. import { defineConfig, loadEnv } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import { resolve } from "path";
  4. import ElementPlus from "unplugin-element-plus/vite";
  5. import { AppType, AppConstant } from "./src/app/appType";
  6. import { appConstant } from "./src/app/fire/constant";
  7. // import { appConstant } from "./src/app/criminal/constant";
  8. export default async ({ mode }) => {
  9. const app = AppType.fire;
  10. // const appConstant = (await import(`./src/app/${app}/constant`))
  11. // .AppConstant as AppConstant;
  12. return defineConfig({
  13. define: {
  14. VITE_APP_APP: JSON.stringify(app),
  15. },
  16. resolve: {
  17. alias: [
  18. {
  19. find: "@",
  20. replacement: resolve(__dirname, "./src"),
  21. },
  22. ],
  23. },
  24. css: {
  25. preprocessorOptions: {
  26. scss: {
  27. additionalData: `@use "${appConstant.useScssPath}" as *;`,
  28. },
  29. },
  30. },
  31. plugins: [
  32. vue(),
  33. ElementPlus({
  34. useSource: true,
  35. }),
  36. ],
  37. server: {
  38. // https:true,
  39. // port:8080,
  40. // 设置代理proxy
  41. proxy: {
  42. "/api": {
  43. // target: 'http://192.168.0.135:8585/',
  44. target: "http://test-mix3d.4dkankan.com",
  45. // target: 'https://testhuodiao.4dkankan.com/',
  46. changeOrigin: true,
  47. rewrite: (path) => path.replace(new RegExp(`^/api`), ""),
  48. },
  49. "/fusion": {
  50. target: "https://test-mix3d.4dkankan.com",
  51. changeOrigin: true,
  52. rewrite: (path) => path.replace(new RegExp(`^/api`), "/fusion"),
  53. },
  54. "/dev-code": {
  55. target: "https://test-mix3d.4dkankan.com/code",
  56. changeOrigin: true,
  57. rewrite: (path) => path.replace(new RegExp(`^/dev-code`), ""),
  58. },
  59. "/swkk": {
  60. target: "https://test.4dkankan.com",
  61. changeOrigin: true,
  62. rewrite: (path) => path.replace(new RegExp(`^/swkk`), ""),
  63. },
  64. "/service": {
  65. target: "https://test.4dkankan.com",
  66. changeOrigin: true,
  67. },
  68. "/swss": {
  69. target: "https://uat-laser.4dkankan.com/uat",
  70. changeOrigin: true,
  71. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  72. },
  73. "/laser": {
  74. target: "https://uat-laser.4dkankan.com",
  75. changeOrigin: true,
  76. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  77. },
  78. "/fdkk": {
  79. target: "https://uat-laser.4dkankan.com",
  80. changeOrigin: true,
  81. rewrite: (path) => path.replace(new RegExp(`^/swss`), ""),
  82. },
  83. },
  84. },
  85. });
  86. };