import { defineConfig } from "vite";
import path from "path";
import uni from "@dcloudio/vite-plugin-uni";

export default defineConfig(({ mode, command }) => {
  return {
    base: "./", // 打包路径
    server: {
      hmr: true, //热更新
      host: true, //指定服务器
      open: true, //自动打开浏览器
      port: 81, //启动端口
      proxy: {
        "/dev-api": {
          target: "http://172.16.120.165:13200",
          ws: true,
          changeOrigin: true,
          //rewrite: (p) => p.replace(/^\/dev-api/, '')
        },
        "/prod-api": {
          target: "https://gateway.usky.cn",
          ws: true,
          changeOrigin: true,
          //rewrite: (p) => p.replace(/^\/dev-api/, '')
        },
      },
    },
    plugins: [uni()],
    resolve: {
      alias: {
        "@/": path.resolve(__dirname, "src"),
        "@/static": path.resolve(__dirname, "src/static"),
        "@/utils": path.resolve(__dirname, "src/utils"),
      },
    },
    configureWebpack: {
      externals: {
        AMap: "AMap",
      },
    },
  };
});
