/** * `@nifrajs/web/plugins/postcss` - a PostCSS (`*.css`, `*.pcss`, `*.postcss`) Bun plugin, in its OWN * module so the SSR preload registers it BEFORE any CSS file loads. Mirrors `@nifrajs/web/plugins/scss`: * pass `"dom"` for the client bundle (`buildClient({ plugins: [...] })`) and preload `"ssr"` for the * server (`bun --preload`). * * PostCSS (`postcss`) is an **optional peer**, not a hard dependency: it's loaded on the first CSS file * and fails loud with an install hint if absent. The plugin list comes from an explicit `plugins` * option, or - when omitted - from the project's `postcss.config.js`, loaded via the optional * `postcss-load-config` peer. This is the Tailwind v4 path: a config with `@tailwindcss/postcss` runs * inside PostCSS, so `app.css` importing `tailwindcss` is compiled during `Bun.build` with no * framework-specific code (v4 bundles its own Lightning CSS, so no separate autoprefixer step). * * Composes with CSS Modules: a `*.module.css` / `*.module.pcss` file is processed and then run through * the same scoped-class transform as `@nifrajs/web/plugins/css-modules`, so `import styles` yields the * `{ original: scoped }` map (SSR/dom class-map parity). A plain CSS file is a side-effect import - its * CSS is bundled (dom) and it resolves to an empty module (ssr). */ import type { BunPlugin } from "bun"; /** The subset of the `postcss` API this plugin uses (structural, so no hard dependency on its types). */ export type PostcssProcessor = (plugins?: readonly unknown[]) => { process(css: string, options: { readonly from?: string; readonly to?: string; }): PromiseLike<{ readonly css: string; }>; }; /** The subset of `postcss-load-config` this plugin uses when no explicit `plugins` are given. */ export type PostcssConfigLoader = (ctx?: Record, path?: string) => Promise<{ readonly plugins?: readonly unknown[]; readonly options?: Record; }>; export interface PostcssPluginOptions { /** Inject the `postcss` function (default: the optional peer, loaded lazily). Pass a stub in tests. */ readonly postcss?: PostcssProcessor; /** PostCSS plugins to run. When omitted, the project's `postcss.config.js` is loaded instead. */ readonly plugins?: readonly unknown[]; /** Directory (or file) to load `postcss.config.js` from, when `plugins` is omitted. Default: cwd. */ readonly config?: string; /** Inject the config loader (default: the `postcss-load-config` optional peer). */ readonly loadConfig?: PostcssConfigLoader; } /** * The PostCSS Bun plugin. `"dom"` → bundles the processed CSS (and, for `*.module.*`, exports the * scoped class map); `"ssr"` → the class map only for `*.module.*`, an empty module for plain CSS. * Tolerates a trailing `?query` (dev servers append one to bust Bun's import cache). */ export declare function postcssBunPlugin(generate: "dom" | "ssr", options?: PostcssPluginOptions): BunPlugin; //# sourceMappingURL=postcss.d.ts.map