vite.config.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { defineConfig } from "vite";
  2. import path from "path";
  3. import uni from "@dcloudio/vite-plugin-uni";
  4. export default defineConfig(({ mode, command }) => {
  5. return {
  6. base: "./", // 打包路径
  7. server: {
  8. hmr: true, //热更新
  9. host: true, //指定服务器
  10. open: true, //自动打开浏览器
  11. port: 81, //启动端口
  12. proxy: {
  13. "/dev-api": {
  14. target: "http://192.168.123.10:13200",
  15. ws: true,
  16. changeOrigin: true,
  17. //rewrite: (p) => p.replace(/^\/dev-api/, '')
  18. },
  19. "/prod-api": {
  20. target: "https://gateway.usky.cn",
  21. ws: true,
  22. changeOrigin: true,
  23. //rewrite: (p) => p.replace(/^\/dev-api/, '')
  24. },
  25. },
  26. },
  27. plugins: [
  28. uni({
  29. vueOptions: {
  30. template: {
  31. compilerOptions: {
  32. // 原生插件组件,勿当 Vue 组件解析(消除 Failed to resolve component 警告)
  33. isCustomElement: (tag) => tag === "door-camera-x" || tag === "my-face-camera",
  34. },
  35. },
  36. },
  37. }),
  38. ],
  39. resolve: {
  40. alias: {
  41. "@/": path.resolve(__dirname, "src"),
  42. "@/static": path.resolve(__dirname, "src/static"),
  43. "@/utils": path.resolve(__dirname, "src/utils"),
  44. },
  45. },
  46. };
  47. });