PostCSS CLI is a command line interface for PostCSS
Install
npm i -D postcss postcss-cli
Usage
Usage: postcss [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w] postcss <input.css>... [OPTIONS] --dir <output-directory> [--watch|-w] postcss <input-directory> [OPTIONS] --dir <output-directory> [--watch|-w] postcss <input-glob-pattern> [OPTIONS] --dir <output-directory> [--watch|-w] postcss <input.css>... [OPTIONS] --replaceBasic options: -o, --output Output file [string] -d, --dir Output directory [string] -r, --replace Replace (overwrite) the input file [boolean] -m, --map Create an external sourcemap --no-map Disable the default inline sourcemaps -w, --watch Watch files for changes and recompile as needed [boolean] --verbose Be verbose [boolean] --env A shortcut for setting NODE_ENV [string]Options for use without a config file: -u, --use List of postcss plugins to use [array] --parser Custom postcss parser [string] --stringifier Custom postcss stringifier [string] --syntax Custom postcss syntax [string]Options for use with --dir: --ext Override the output file extension; for use with --dir [string] --base Mirror the directory structure relative to this path in the output
ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found here.
Note that you can not set the from or to options for postcss in the config file. They are set automatically based on the CLI arguments.
Context
For more advanced usage, it's recommended to use a function in postcss.config.js; this gives you access to the CLI context to dynamically apply options and plugins per file