vite.config.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  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://172.16.120.165: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: [uni()],
  28. resolve: {
  29. alias: {
  30. "@/": path.resolve(__dirname, "src"),
  31. "@/static": path.resolve(__dirname, "src/static"),
  32. "@/utils": path.resolve(__dirname, "src/utils"),
  33. },
  34. },
  35. configureWebpack: {
  36. externals: {
  37. AMap: "AMap",
  38. },
  39. },
  40. };
  41. });