@nibcss/cli

Every command and flag of the nib CLI, the files it writes, and its Node API for custom pipelines.

1 min readv1

Commands#

Command

What it does

nib init

create nibcss.config.ts, fully commented

nib build

scan once, write the stylesheet and the config files

nib watch

the same, then rebuild on every change (about 50 ms)

Flags#

Flag

Default

What it does

-o, --out <file>

nib.css

where the stylesheet goes; the config files are written beside it

--content <glob>

project sources

globs to scan, repeatable; node_modules, dist and .git are always skipped

--minify

off

strip comments and whitespace

-c, --config <file>

auto-detected

a config file somewhere else

What it writes#

File

For

<out>.css

the stylesheet — link it

<out>.config.js

sets window.__NIB__, for a classic <script>

<out>.config.mjs

the same data as a module, plus node_modules/@nibcss/config

The Node API#

TypeScript
import { build, watch, init } from "@nibcss/cli";

const result = await build({
  out: "public/nib.css",
  content: ["resources/views/**/*.blade.php"],
  minify: true,
});

console.log(result);   // what was written, and the engine stats

const watcher = await watch({ out: "public/nib.css", content: ["resources/views/**/*.blade.php"] });
// …
await watcher.close();

Export

What it is

build(options): Promise<BuildResult>

one pass

watch(options): Promise<Watcher>

the same, then rebuild on change; close() stops it

init(options)

write the config file

BuildOptions, BuildResult, Watcher

the types

This is what a Rails or Laravel pipeline reaches for when npm run is not where the build lives.

Next steps#