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
857 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
75 /100 Good
Development Activity 80
Maintenance 64
Community 68
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
65 /100 Good
Architecture 68
Code Quality 78
Innovation 82
Learning Curve 30

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
83%
Apache 2.0

Authelia

Authentication · Security

29,110

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

View details
91
Repo Health
81
Technical
75
Dependency
Built with
Go 83%
TypeScript 15%
Updated 5 days ago
Python
84%
Other

Bugsink

Developer Tools · Monitoring

2,095

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
Python 84%
HTML 14%
Updated 1 weeks ago
TypeScript
96%
Other

Cal.diy

Scheduling

48,697

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

View details
91
Repo Health
86
Technical
65
Dependency
Built with
TypeScript 96%
Updated 6 days ago
Ruby
64%
AGPL 3.0

Forem

Blogging · Community

22,783

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
Ruby 64%
JavaScript 19%
HTML 13%
Updated 6 days ago
TypeScript
51%
MIT

Ghost

Blogging · CMS

55,450

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
TypeScript 51%
JavaScript 44%
Updated 4 days ago
Rust
65%
Other

GitButler

AI Development · Developer Tools · Devops

21,726

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
66
Dependency
Built with
Rust 65%
TypeScript 22%
Svelte 10%
Updated 4 days ago
Go
64%
MIT

hoop

Monitoring · Security

823

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
Go 64%
Clojure 17%
JavaScript 11%
Updated 1 weeks ago
Elixir
71%
AGPL 3.0

Keila

Marketing

2,224

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
84
Repo Health
76
Technical
72
Dependency
Built with
Elixir 71%
HTML 18%
Updated 1 weeks ago
Go
97%
Apache 2.0

kopia

File Storage

14,209

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
Go 97%
Updated 5 days ago

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