#!/usr/bin/env node // Compile .design-sync/tailwind-entry.css → .design-sync/compiled.css. // // The repo only depends on @tailwindcss/postcss (Next drives it through // postcss.config.mjs), not @tailwindcss/cli — so this runs the same plugin // directly rather than adding a devDependency just for the sync. // // Re-run before every package-build.mjs: Tailwind generates utilities by // scanning sources, and newly authored .design-sync/previews/*.tsx introduce // classes that aren't in the previous compile. // // node .design-sync/build-css.mjs import { readFileSync, writeFileSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; import { fileURLToPath } from 'node:url'; import postcss from 'postcss'; import tailwind from '@tailwindcss/postcss'; const HERE = dirname(fileURLToPath(import.meta.url)); const from = resolve(HERE, 'tailwind-entry.css'); const to = resolve(HERE, 'compiled.css'); const result = await postcss([tailwind()]).process(readFileSync(from, 'utf8'), { from, to }); for (const w of result.warnings()) console.error(`! ${w.toString()}`); writeFileSync(to, result.css); console.error(`css: ${(result.css.length / 1024).toFixed(0)} KB → ${to}`);