import { defineConfig } from "vite";

export default defineConfig(({ mode }) => {
  const routerUrl =
    process.env.ROUTER_URL || process.env.VITE_ROUTER_URL || "http://localhost:7891";

  return {
    server: {
      port: 5175,
      strictPort: false,
      proxy: {
        "/v1": {
          target: routerUrl,
          changeOrigin: true,
        },
      },
    },
    preview: {
      port: 5176,
    },
    build: {
      outDir: "dist-ui",
      emptyOutDir: true,
    },
    optimizeDeps: {
      include: ["@morpho-dev/router"],
    },
  };
});
