Files
Astro-Component/scripts/make-dist.mjs
T
2025-08-16 09:58:40 +05:30

31 lines
1.1 KiB
JavaScript

// scripts/make-dist.mjs
import fs from "node:fs";
import path from "node:path";
const distDir = path.resolve("dist");
if (!fs.existsSync(distDir)) fs.mkdirSync(distDir, { recursive: true });
const indexJs = `/* Auto-generated by scripts/make-dist.mjs */
export { default as Button } from "../src/components/Button.astro";
export { default as Form } from "../src/components/Form.astro";
export { default as Field } from "../src/components/Field.astro";
export { default as MultiSelect } from "../src/components/MultiSelect.astro";
export { default as Icon } from "../src/components/Icon.astro";
export { cn } from "../src/utils/cn.js";
`;
const indexDts = `/* Auto-generated types (lightweight) */
/// <reference types="astro/client" />
export const Button: any;
export const Form: any;
export const Field: any;
export const MultiSelect: any;
export const Icon: any;
export function cn(...classes: Array<string | number | false | null | undefined>): string;
`;
fs.writeFileSync(path.join(distDir, "index.js"), indexJs, "utf8");
fs.writeFileSync(path.join(distDir, "index.d.ts"), indexDts, "utf8");
console.log("🧱 Wrote dist/index.js and dist/index.d.ts");