import dts from "unplugin-dts/vite"; import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { defineConfig } from "vite"; import { nodePolyfills } from "vite-plugin-node-polyfills"; const __dirname = dirname(fileURLToPath(import.meta.url)); export default defineConfig({ plugins: [ dts({ exclude: ["**/__tests__/*.*"] }), nodePolyfills({ // Specify which polyfills to include (optional, but recommended for bundle size) include: ["buffer"], // Only polyfill 'buffer' (add others like 'process' if needed) // Configure global variables (e.g., expose Buffer to window) globals: { Buffer: true, // Expose Buffer as a global variable (optional but useful for some cases) }, }), ], build: { lib: { entry: resolve(__dirname, "src/index.ts"), name: "twtxt-lib", fileName: "index", formats: ["es"], outDir: "./dist", }, minify: false, }, });