postcss-cli

The command-line runner for PostCSS, transforming CSS files, globs, and directories from the terminal with your existing plugin chain.

Tool
npm
v12.0.0
857stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
77/100Good
Development Activity88
Maintenance64
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
65/100Good
Architecture68
Code Quality78
Innovation82
Learning Curve30

postcss-cli is the official command-line runner for PostCSS, the tool that parses CSS into an AST so plugins can transform it programmatically. It wraps postcss-load-config’s resolution flow, so plugins and options defined in a postcss.config.js are picked up automatically, letting teams standardize how CSS is processed across a project without hand-writing a build script.

Beyond straightforward single-file transforms, postcss-cli supports directory-wide globs via —dir, in-place edits via —replace, and a watch mode built on chokidar that recompiles only the files actually affected by a changed dependency, tracked through an internal dependency graph derived from PostCSS’s own dependency messages. It also handles inline or external source maps, custom parsers/stringifiers/syntaxes, and per-file processing context so a postcss.config.js function can vary options file by file.

What You Get

  • A single binary (the postcss command) that runs your existing postcss.config.js plugin chain against any file, directory, or glob pattern.
  • Directory-wide processing via —dir, optionally mirroring the input folder structure into the output directory with —base.
  • Watch mode that recompiles only the files affected by a changed dependency, tracked via a dependency graph built from PostCSS’s own dependency and dir-dependency messages.
  • Built-in inline or external source map generation, plus support for custom parsers, stringifiers, and syntaxes (e.g. SugarSS) without extra tooling.

Common Use Cases

  • Compiling a CSS bundle through a chain of PostCSS plugins (postcss-import, autoprefixer, cssnano) as part of an npm build script.
  • Replacing a Sass/Less pipeline with plain CSS plus PostCSS plugins configured once in postcss.config.js.
  • Watching a src/ directory during development so edits to any imported partial or config file trigger a targeted recompile.
  • Piping CSS through PostCSS plugins in a shell pipeline (cat input.css | postcss -u autoprefixer > output.css) for one-off transforms.

Under The Hood

Architecture index.js is a single procedural entry point: it parses argv via lib/args.js (yargs), expands glob/dir input with tinyglobby, resolves each file’s config through postcss-load-config (wrapped in a local rc helper that rejects from/to overrides), runs the file through postcss(), and writes output via lib/outputFile.js, which skips the write entirely if content is unchanged. Watch mode layers chokidar on top, tracking which files depend on which via lib/DependencyGraph.js, a thin wrapper around the dependency-graph package that consumes PostCSS’s own dependency/dir-dependency result messages, so a changed partial only triggers recompilation of its actual dependents rather than the whole input set. There’s no framework or DI layer — it’s a small set of single-purpose lib/ modules around one script, with the dependency-tracked watch mode as the one genuinely stateful piece.

Tech Stack The package is pure ESM (“type”: “module”) and requires Node >=22. Runtime dependencies are all narrowly scoped: chokidar (watching), dependency-graph, picocolors (terminal color), postcss-load-config (config resolution), postcss-reporter (warning formatting), pretty-hrtime, read-cache, slash, tinyglobby (globbing), and yargs (argument parsing), with postcss itself as a peer dependency. No bundler is involved — the package ships its plain ESM source (index.js plus lib/) directly per its “files” field. CI runs the Node 22/24/26 matrix on both Ubuntu and Windows via GitHub Actions.

Code Quality The test/ directory holds a broad set of CLI-level integration tests (covering config resolution, directory processing, globbing, source maps, custom parsers/syntaxes, replace mode, stdin/stdout, and watch mode) run with ava, each spawning the actual built binary through a shared test/helpers/cli.js rather than mocking internals, plus a couple of colocated unit tests next to lib/ modules. The ci npm script chains eslint, the ava/c8 coverage run, and a prettier format check, so lint and formatting are enforced before merge. The codebase is plain JavaScript with no static type checking (no TypeScript, no JSDoc type annotations observed).

API Design The CLI mirrors postcss.config.js options directly onto flags (—map/—no-map, —parser, —stringifier, —syntax), so users don’t have to learn a separate flag vocabulary. Defaults are sensible — no output flag falls back to stdout, no input falls back to stdin — and yargs renders a grouped, example-driven —help. Getting started requires minimal boilerplate: npm i -D postcss postcss-cli then postcss input.css -o output.css runs with zero configuration, and error messages name the specific problem (e.g. rejecting --dir/--replace combined with stdin, or from/to overrides in the config file) rather than failing generically.

Used by 18 apps in this directory

Go
86%
Apache 2.0

Authelia

Security · Authentication

28,815

OpenID Certified SSO and MFA portal for securing self-hosted web applications behind reverse proxies.

View details
91
Repo Health
81
Technical
76
Dependency
Built with
Go86%
TypeScript12%
Updated today
Python
83%
Other

Bugsink

Developer Tools · Monitoring

2,056

Self-hosted error tracking that accepts Sentry SDKs out of the box, so you keep your instrumentation and drop the monthly bill.

View details
84
Repo Health
80
Technical
71
Dependency
Built with
Python83%
HTML15%
Updated 3 days ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,218

The 100% MIT-licensed, community-driven scheduling platform — self-host your own booking infrastructure with no enterprise strings attached.

View details
95
Repo Health
86
Technical
65
Dependency
Built with
TypeScript96%
Updated yesterday
Ruby
63%
AGPL 3.0

Forem

Community · Blogging

22,775

Open source Ruby on Rails platform for building developer communities with articles, discussions, and social profiles—the same software that powers dev.to.

View details
83
Repo Health
79
Technical
67
Dependency
Built with
Ruby63%
JavaScript19%
HTML13%
Updated 2 days ago
JavaScript
47%
MIT

Ghost

CMS · Blogging

55,191

Open source headless Node.js CMS for professional publishing, paid memberships, and newsletters with a fully owned audience.

View details
96
Repo Health
85
Technical
67
Dependency
Built with
JavaScript47%
TypeScript47%
Updated yesterday
Rust
67%
Other

GitButler

Developer Tools · Devops · AI Development

21,624

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
67
Dependency
Built with
Rust67%
TypeScript20%
Svelte11%
Updated yesterday
Go
60%
MIT

hoop

Security · Monitoring

807

A wire-protocol gateway that enforces data masking, command blocking, approval workflows, and full session recording for engineers and AI agents accessing production infrastructure.

View details
85
Repo Health
80
Technical
64
Dependency
Built with
Go60%
Clojure19%
JavaScript14%
Updated 3 days ago
Elixir
71%
AGPL 3.0

Keila

Marketing

2,203

Self-hosted newsletter platform with a visual block editor, Liquid personalization, and flexible email delivery — a privacy-respecting Mailchimp alternative you run on your own infrastructure.

View details
88
Repo Health
76
Technical
71
Dependency
Built with
Elixir71%
HTML18%
Updated yesterday
Go
97%
Apache 2.0

kopia

File Storage

14,054

Fast, encrypted, deduplicated backups to any cloud or local storage with full client-side control.

View details
91
Repo Health
83
Technical
68
Dependency
Built with
Go97%
Updated yesterday

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search