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

export default defineConfig({
  build: {
    emptyOutDir: true,
    outDir: "../../dist/web",
    rolldownOptions: {
      output: {
        codeSplitting: {
          groups: [
            {
              name: "vendor-react",
              test: /[\\/]node_modules[\\/](react|react-dom|scheduler)[\\/]/,
            },
            {
              name: "vendor-tdesign",
              test: /[\\/]node_modules[\\/](tdesign-react|tdesign-icons-react)[\\/]/,
            },
            {
              name: "vendor-chart",
              test: /[\\/]node_modules[\\/](recharts|d3-.*)[\\/]/,
            },
          ],
        },
      },
    },
  },
  plugins: [react()],
  root: "src/web",
  server: {
    proxy: {
      "/api": "http://127.0.0.1:3000",
      "/health": "http://127.0.0.1:3000",
    },
  },
});
