vite.config.ts 2.4 KB

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