vite.config.ts 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. import { defineConfig } from "vite";
  2. import vue from "@vitejs/plugin-vue";
  3. import AutoImport from "unplugin-auto-import/vite";
  4. import Components from "unplugin-vue-components/vite";
  5. import { VantResolver } from "@vant/auto-import-resolver";
  6. import { fileURLToPath, URL } from "node:url";
  7. export default defineConfig({
  8. base: './',
  9. plugins: [
  10. vue(),
  11. AutoImport({
  12. resolvers: [VantResolver()],
  13. }),
  14. Components({
  15. resolvers: [VantResolver()],
  16. }),
  17. ],
  18. resolve: {
  19. alias: {
  20. "@": fileURLToPath(new URL("./src", import.meta.url)),
  21. },
  22. extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json", ".vue"],
  23. },
  24. server: {
  25. //方式二:设置多个代理
  26. proxy: {
  27. //这个路径为http://192.168.1.182:3000/douyu/wgapi/vod/front/vodrank/getTagVideos
  28. "/ucenter": {
  29. //target是代理的目标路径
  30. target: "https://v4-uat.4dkankan.com",
  31. changeOrigin: true, //必须要开启跨域
  32. //pathRewrite重写请求的路径,实际请求的路径没有代理标识douyu,需要把斗鱼重置为空字符串
  33. // rewrite: (path) => path.replace(/\/ucenter/, ""), // 路径重写
  34. },
  35. "/service": {
  36. //target是代理的目标路径
  37. target: "https://v4-uat.4dkankan.com",
  38. changeOrigin: true, //必须要开启跨域
  39. //pathRewrite重写请求的路径,实际请求的路径没有代理标识douyu,需要把斗鱼重置为空字符串
  40. // rewrite: (path) => path.replace(/\/service/, ""), // 路径重写
  41. },
  42. },
  43. },
  44. });