2025-01-24 01:29:15 -05:00

86 lines
1.8 KiB
TypeScript
Executable File

#!/usr/bin/env bun
import { promises as fs } from "node:fs";
import { pick } from "lodash-es";
import { build, defineConfig } from "tsup";
import pkg from "../package.json" with { type: "json" };
const tsupConfig = defineConfig({
outDir: "dist",
splitting: false,
sourcemap: false,
dts: true,
treeshake: true,
platform: "node",
format: "esm",
banner: {
js: "/* eslint-disable */",
},
define: {
__PKG_NAME__: JSON.stringify(pkg.name),
},
});
await build({
...tsupConfig,
entry: ["src/classed.tsx", "src/css-to-js.ts"],
outDir: "dist",
external: ["react", "react/jsx-runtime", "clsx"],
clean: true,
});
await Promise.all([
build({
...tsupConfig,
entry: ["src/classed.tsx", "src/css-to-js.ts"],
outDir: "dist",
external: ["react", "react/jsx-runtime", "clsx"],
}),
build({
...tsupConfig,
entry: ["src/index.ts"],
external: ["postcss-selector-parser", "postcss", "stylis"],
}),
...[
"animate",
"aspect-ratio",
"container-queries",
"forms",
"react-aria-components",
"typography",
].map(name =>
build({
...tsupConfig,
entry: [`./src/vendor/${name}.ts`],
outDir: "dist/vendor",
external: ["tailwindcss/plugin", "tailwindcss/colors", "tailwindcss/defaultTheme"],
})
),
Bun.write(
"dist/package.json",
JSON.stringify(
pick(pkg, [
"name",
"version",
"type",
"license",
"dependencies",
"author",
"exports",
]),
null,
2
).replaceAll("./dist/", "./")
),
]);
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"),
Bun.write(`dist/base.d.ts`, `/**\n * \`@tailwind base\` component.\n */\nexport {};`),
]);
process.exit(0);