Official command-line interface for PostCSS, the popular CSS post-processor. Current stable version is 11.0.1 (2024-05-??). PostCSS CLI allows you to run PostCSS plugins from the terminal, supporting input/output files, directories, glob patterns, stdin/stdout piping, and watch mode. It requires Node ≥18 and PostCSS ≥8 as a peer dependency. Unlike alternative tools like PostCSS's programmatic API or build tool plugins, this CLI is designed for direct command-line usage and scripting, with support for configuration files (postcss.config.js), custom parsers/syntaxes, and sourcemaps. Version 8.0.0 made PostCSS a peer dependency, and version 7.0.0 dropped Node 6 & 8 support. The tool is actively maintained by the PostCSS core team.
npm install postcss-cliVerified import paths — ran on the pinned version, not inferred.
Installation and common CLI usage patterns: basic output, watch mode, config file, glob/dir, piping, and env variables.
Install postcss alongside postcss-cli: npm install --save-dev postcss postcss-cli
Upgrade Node to v18 or later, or use an older version of postcss-cli.
Ensure you have the correct PostCSS version installed: npm install postcss@8
Add --verbose flag to see detailed output, or check exit codes and output files.
Use long option names (e.g., --output, --dir, --version).
Remove 'from'/'to' from your postcss.config.js; the CLI handles them automatically.
Run: npm install postcss@8 --save-dev
Use npx postcss or install globally: npm install -g postcss postcss-cli. Alternatively, add a script in package.json.
Remove `from` and `to` from your config file; they are automatically supplied by the CLI.