import { defineConfig } from "vite"
import { resolve } from "node:path"
import { fileURLToPath } from "node:url"

const __dirname = fileURLToPath(new URL(".", import.meta.url))

export default defineConfig({
  build: {
    lib: {
      entry: {
        global: resolve(__dirname, "assets/typescript/main.ts"),
      },
      formats: ["es"],
      fileName: (format, entryName) => `${entryName}.js`,
    },
    outDir: "assets/script",
    emptyOutDir: false,
    rollupOptions: {
      output: {
        dir: "assets/script",
        entryFileNames: "[name].js",
      },
    },
  },
})
