import vue from "@vitejs/plugin-vue";
import { defineConfig } from "vite";

export default defineConfig({
  base: "/login/",
  plugins: [vue()],
  build: {
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (!id.includes("node_modules")) return undefined;
          if (id.includes("element-plus/es/components/table")) return "el-table";
          if (
            id.includes("/vue/") ||
            id.includes("@vue/") ||
            id.includes("@vueuse") ||
            id.includes("async-validator") ||
            id.includes("@popperjs") ||
            id.includes("@floating-ui") ||
            id.includes("dayjs")
          ) {
            return "vendor";
          }
          return undefined;
        },
      },
    },
  },
  server: {
    allowedHosts: ["qa.huiyushuyuan.cn"],
    host: "0.0.0.0",
    port: 5174,
    proxy: {
      "/api": {
        target: "http://backend:8100",
        changeOrigin: true,
      },
    },
  },
});
