import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { resolve } from "path";
import tailwindcss from "@tailwindcss/vite";
import dts from "unplugin-dts/vite";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react(), tailwindcss(), dts({ bundleTypes: true })],
  build: {
    target: "es2020",
    lib: {
      entry: resolve(__dirname, "src/threeStore.ts"),
      name: "ThreeStore",
      formats: ["umd", "es"], // es 无法压缩，但是破坏tree shaking
      // the proper extensions will be added
      fileName: "three-store",
    },
    rolldownOptions: {
      // 确保外部化处理那些你不想打包进库的依赖
      external: ["three"],
      // output: {
      //   // 在 UMD 构建模式下为这些外部化的依赖提供一个全局变量
      //   globals: {
      //     vue: "Vue",
      //   },
      // },
    },
  },
});
