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

export default defineConfig({
  build: {
    rollupOptions: {
      input: {
        admin: new URL("./index.html", import.meta.url).pathname,
        databi: new URL("./databi/index.html", import.meta.url).pathname
      }
    }
  },
  css: {
    modules: {
      generateScopedName: "hy-[name]__[local]__[hash:base64:5]",
      localsConvention: "camelCaseOnly"
    }
  },
  resolve: {
    alias: {
      "@": new URL("./src", import.meta.url).pathname
    },
    dedupe: ["react", "react-dom", "@emotion/react", "@emotion/styled"]
  },
  optimizeDeps: {
    include: [
      "@emotion/react",
      "@emotion/styled",
      "@mui/material/MenuItem",
      "@mui/material/Select",
      "@mui/material/TextField",
      "@mui/material/styles",
      "react",
      "react-dom",
      "react-dom/client",
      "react/jsx-dev-runtime",
      "react/jsx-runtime"
    ]
  },
  plugins: [react()],
  server: {
    port: 7001,
    proxy: {
      "/api": {
        target: "http://localhost:13100",
        changeOrigin: true
      }
    }
  },
  preview: {
    port: 7001
  },
  test: {
    environment: "jsdom",
    setupFiles: "./src/test/setup.js"
  }
});
