import react from "@vitejs/plugin-react";
import { resolve } from "path";
import { defineConfig } from "vite";
import dts from "vite-plugin-dts";
import { alias } from "./vite.config";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), dts({ include: ["lib"] })],
  resolve: {
    alias,
  },
  build: {
    lib: {
      entry: resolve(__dirname, "lib/index.ts"),
      formats: ["es"],
      fileName: "index",
    },
    outDir: "dist-package",
    copyPublicDir: false,
    minify: false,
    rollupOptions: {
      external: [
        "@emoji-mart/data",
        "@emoji-mart/react",
        "@emotion/react",
        "@emotion/styled",
        "@mui/icons-material",
        "@mui/material",
        "@mui/x-date-pickers",
        "axios",
        "emoji-mart",
        "immer",
        "moment",
        "nanoid",
        "notistack",
        "react-dom",
        "react-error-boundary",
        "react-router-dom",
        "react",
        "swr",
        "use-debounce",
        "zustand",
      ],
    },
  },
});
