2024-07-03 01:04:49 -04:00

51 lines
1.1 KiB
TypeScript
Executable File

#!/usr/bin/env bun
import { promises as fs } from "node:fs";
import { build, defineConfig } from "tsup";
import { pick } from "lodash";
import pkg from "../package.json" with { type: "json" };
const tsupConfig = defineConfig({
outDir: "dist",
splitting: false,
sourcemap: false,
dts: true,
treeshake: true,
platform: "node",
banner: {
js: "/* eslint-disable */",
},
});
await Promise.all([
build({
...tsupConfig,
entry: ["src/classed.tsx"],
outDir: "dist",
external: ["react", "react/jsx-runtime", "clsx"],
format: "esm",
clean: true,
}),
build({
...tsupConfig,
entry: ["src/index.ts"],
external: ["postcss-selector-parser", "postcss", "stylis"],
}),
Bun.write(
"dist/package.json",
JSON.stringify(
pick(pkg, ["name", "version", "license", "dependencies", "author"]),
null,
2
)
),
Bun.write(`dist/base.d.ts`, `/**\n * \`@tailwind base\` component.\n */\nexport {};`),
]);
await Promise.all([
fs.copyFile("README.md", "dist/README.md"),
fs.copyFile("LICENSE.md", "dist/LICENSE.md"),
fs.copyFile("src/macro.d.ts", "dist/macro.d.ts"),
]);
process.exit(0);