import { defineConfig } from "vite"; import react from "@vitejs/plugin-react"; import path from "path"; export default defineConfig(({ command }) => { if (command === "serve") { return { plugins: [react()], root: "playground", }; } return { plugins: [react()], build: { cssMinify: false, lib: { entry: path.resolve(import.meta.dirname, "src/index.ts"), formats: ["es", "cjs"], fileName: (format) => `index.${format}.js`, }, rolldownOptions: { external: ["react", "react-dom", "react/jsx-runtime"], output: { globals: { react: "React", "react-dom": "ReactDOM", }, }, }, emptyOutDir: true, sourcemap: true, cssCodeSplit: false, outDir: "dist", }, }; });