import tailwindcss from "@tailwindcss/vite";
import { presetIcons } from "@unocss/preset-icons";
import UnoCSS from "@unocss/vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [
    react(),
    tailwindcss(),
    UnoCSS({
      presets: [presetIcons()],
    }),
  ],
  resolve: {
    alias: {
      "@": fileURLToPath(new URL("./src", import.meta.url)),
    },
  },
  server: {
    port: 5173,
    proxy: {
      "/api": "http://localhost:3000",
      "/docs": "http://localhost:3000",
      "/mcp": "http://localhost:3000",
      "/openapi.json": "http://localhost:3000",
      "/v1": "http://localhost:3000",
    },
  },
  build: {
    outDir: "../dist/web",
    emptyOutDir: true,
    rollupOptions: {
      output: {
        manualChunks(id) {
          if (id.includes("/node_modules/recharts/")) {
            return "charts";
          }
        },
      },
    },
  },
});
