73 lines
1.6 KiB
TypeScript
Executable File
73 lines
1.6 KiB
TypeScript
Executable File
#!/usr/bin/env tsx
|
|
import { promises as fs } from "node:fs";
|
|
|
|
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/utils.tsx", "src/css-to-js.ts"],
|
|
outDir: "dist",
|
|
external: ["react", "react/jsx-runtime", "clsx"],
|
|
clean: true,
|
|
});
|
|
|
|
await Promise.all([
|
|
build({
|
|
...tsupConfig,
|
|
entry: ["src/utils.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"],
|
|
})
|
|
),
|
|
]);
|
|
|
|
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"),
|
|
fs.copyFile("src/react-env.d.ts", "dist/react-env.d.ts"),
|
|
fs.writeFile(
|
|
`dist/base.d.ts`,
|
|
`/**\n * \`@tailwind base\` component.\n */\nexport {};`
|
|
),
|
|
]);
|
|
|
|
process.exit(0);
|