Gathering detailed insights and metrics for postcss-cli
Gathering detailed insights and metrics for postcss-cli
Gathering detailed insights and metrics for postcss-cli
Gathering detailed insights and metrics for postcss-cli
npm install postcss-cli
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
842 Stars
502 Commits
93 Forks
13 Watching
9 Branches
60 Contributors
Updated on 26 Nov 2024
JavaScript (100%)
Cumulative downloads
Total Downloads
Last day
-0.9%
139,416
Compared to previous day
Last week
1.3%
736,564
Compared to previous week
Last month
11.4%
3,109,920
Compared to previous month
Last year
18.7%
34,830,588
Compared to previous year
PostCSS CLI is a command line interface for PostCSS
1npm i -D postcss postcss-cli
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] --replace
Basic 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
directory, for use with --dir [string]
Advanced options:
--include-dotfiles Enable glob to match files/dirs that begin with "."
[boolean]
--poll Use polling for file watching. Can optionally pass polling
interval; default 100 ms
--config Set a custom directory to look for a config file [string]
Options:
--version Show version number [boolean]
-h, --help Show help [boolean]
Examples:
postcss input.css -o output.css Basic usage
postcss src/**/*.css --base src --dir build Glob Pattern & output
cat input.css | postcss -u autoprefixer > output.css Piping input & output
If no input files are passed, it reads from stdin. If neither -o, --dir, or
--replace is passed, it writes to stdout.
If there are multiple input files, the --dir or --replace option must be passed.
Input files may contain globs (e.g. src/**/*.css). If you pass an input
directory, it will process all files in the directory and any subdirectories,
respecting the glob pattern.
ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found here.
If you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file.
postcss.config.js
1module.exports = { 2 parser: 'sugarss', 3 plugins: [ 4 require('postcss-import')({ ...options }), 5 require('postcss-url')({ url: 'copy', useHash: true }), 6 ], 7}
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.
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
Name | Type | Default | Description |
---|---|---|---|
env | {String} | 'development' | process.env.NODE_ENV |
file | {Object} | dirname, basename, extname | File |
options | {Object} | map, parser, syntax, stringifier | PostCSS Options |
postcss.config.js
1module.exports = (ctx) => ({ 2 map: ctx.options.map, 3 parser: ctx.file.extname === '.sss' ? 'sugarss' : false, 4 plugins: { 5 'postcss-import': { root: ctx.file.dirname }, 6 cssnano: ctx.env === 'production' ? {} : false, 7 }, 8})
⚠️ If you want to set options via CLI, it's mandatory to reference
ctx.options
inpostcss.config.js
1postcss input.sss -p sugarss -o output.css -m
postcss.config.js
1module.exports = (ctx) => ({ 2 map: ctx.options.map, 3 parser: ctx.options.parser, 4 plugins: { 5 'postcss-import': { root: ctx.file.dirname }, 6 cssnano: ctx.env === 'production' ? {} : false, 7 }, 8})
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 3/9 approved changesets -- score normalized to 3
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More