{"id":13630960,"url":"https://github.com/postcss/postcss-cli","last_synced_at":"2025-05-12T13:28:21.883Z","repository":{"id":3737218,"uuid":"50738648","full_name":"postcss/postcss-cli","owner":"postcss","description":"CLI for postcss","archived":false,"fork":false,"pushed_at":"2025-03-12T17:42:32.000Z","size":413,"stargazers_count":849,"open_issues_count":14,"forks_count":96,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-05-08T11:25:15.956Z","etag":null,"topics":["cli","postcss","postcss-runner"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/postcss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-30T18:33:59.000Z","updated_at":"2025-05-02T06:11:45.000Z","dependencies_parsed_at":"2024-04-12T09:21:49.052Z","dependency_job_id":"4f819375-335c-4cf3-b5c0-f87ea056c555","html_url":"https://github.com/postcss/postcss-cli","commit_stats":{"total_commits":470,"total_committers":53,"mean_commits":8.867924528301886,"dds":0.676595744680851,"last_synced_commit":"0f52be713e121c7e4476b380ce7bab9529890b7c"},"previous_names":[],"tags_count":58,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/postcss%2Fpostcss-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/postcss","download_url":"https://codeload.github.com/postcss/postcss-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253351713,"owners_count":21895024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","postcss","postcss-runner"],"created_at":"2024-08-01T22:02:04.684Z","updated_at":"2025-05-12T13:28:21.861Z","avatar_url":"https://github.com/postcss.png","language":"JavaScript","readme":"[![npm][npm]][npm-url]\n[![node][node]][node-url]\n[![tests][tests]][tests-url]\n[![cover][cover]][cover-url]\n[![chat][chat]][chat-url]\n\n\u003cdiv align=\"center\"\u003e\n  \u003cimg width=\"100\" height=\"100\" title=\"CLI\" src=\"https://raw.githubusercontent.com/postcss/postcss-cli/HEAD/logo.svg\"\u003e\n  \u003ca href=\"https://github.com/postcss/postcss\"\u003e\n    \u003cimg width=\"110\" height=\"110\" title=\"PostCSS\" src=\"http://postcss.github.io/postcss/logo.svg\" hspace=\"10\"\u003e\n  \u003c/a\u003e\n  \u003ch1\u003ePostCSS CLI\u003c/h1\u003e\n\u003c/div\u003e\n\nPostCSS CLI is a command line interface for [PostCSS](https://postcss.org/)\n\n\u003ch2 align=\"center\"\u003eInstall\u003c/h2\u003e\n\n```bash\nnpm i -D postcss postcss-cli\n```\n\n\u003ch2 align=\"center\"\u003eUsage\u003c/h2\u003e\n\n```\nUsage:\n  postcss [input.css] [OPTIONS] [-o|--output output.css] [--watch|-w]\n  postcss \u003cinput.css\u003e... [OPTIONS] --dir \u003coutput-directory\u003e [--watch|-w]\n  postcss \u003cinput-directory\u003e [OPTIONS] --dir \u003coutput-directory\u003e [--watch|-w]\n  postcss \u003cinput-glob-pattern\u003e [OPTIONS] --dir \u003coutput-directory\u003e [--watch|-w]\n  postcss \u003cinput.css\u003e... [OPTIONS] --replace\n\nBasic options:\n  -o, --output   Output file                                            [string]\n  -d, --dir      Output directory                                       [string]\n  -r, --replace  Replace (overwrite) the input file                    [boolean]\n  -m, --map      Create an external sourcemap\n  --no-map       Disable the default inline sourcemaps\n  -w, --watch    Watch files for changes and recompile as needed       [boolean]\n  --verbose      Be verbose                                            [boolean]\n  --env          A shortcut for setting NODE_ENV                        [string]\n\nOptions for use without a config file:\n  -u, --use      List of postcss plugins to use                          [array]\n  --parser       Custom postcss parser                                  [string]\n  --stringifier  Custom postcss stringifier                             [string]\n  --syntax       Custom postcss syntax                                  [string]\n\nOptions for use with --dir:\n  --ext   Override the output file extension; for use with --dir        [string]\n  --base  Mirror the directory structure relative to this path in the output\n          directory, for use with --dir                                 [string]\n\nAdvanced options:\n  --include-dotfiles  Enable glob to match files/dirs that begin with \".\"\n                                                                       [boolean]\n  --poll              Use polling for file watching. Can optionally pass polling\n                      interval; default 100 ms\n  --config            Set a custom directory to look for a config file  [string]\n\nOptions:\n  --version   Show version number                                      [boolean]\n  -h, --help  Show help                                                [boolean]\n\nExamples:\n  postcss input.css -o output.css                       Basic usage\n  postcss src/**/*.css --base src --dir build           Glob Pattern \u0026 output\n  cat input.css | postcss -u autoprefixer \u003e output.css  Piping input \u0026 output\n\nIf no input files are passed, it reads from stdin. If neither -o, --dir, or\n--replace is passed, it writes to stdout.\n\nIf there are multiple input files, the --dir or --replace option must be passed.\n\nInput files may contain globs (e.g. src/**/*.css). If you pass an input\ndirectory, it will process all files in the directory and any subdirectories,\nrespecting the glob pattern.\n```\n\n\u003e ℹ️ More details on custom parsers, stringifiers and syntaxes, can be found [here](https://github.com/postcss/postcss#syntaxes).\n\n### [Config](https://github.com/michael-ciniawsky/postcss-load-config)\n\nIf you need to pass options to your plugins, or have a long plugin chain, you'll want to use a configuration file.\n\n**postcss.config.js**\n\n```js\nmodule.exports = {\n  parser: 'sugarss',\n  plugins: [\n    require('postcss-import')({ ...options }),\n    require('postcss-url')({ url: 'copy', useHash: true }),\n  ],\n}\n```\n\nNote 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.\n\n### Context\n\nFor 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**\n\n|   Name    |    Type    |              Default               | Description          |\n| :-------: | :--------: | :--------------------------------: | :------------------- |\n|   `env`   | `{String}` |          `'development'`           | process.env.NODE_ENV |\n|  `file`   | `{Object}` |    `dirname, basename, extname`    | File                 |\n| `options` | `{Object}` | `map, parser, syntax, stringifier` | PostCSS Options      |\n\n**postcss.config.js**\n\n```js\nmodule.exports = (ctx) =\u003e ({\n  map: ctx.options.map,\n  parser: ctx.file.extname === '.sss' ? 'sugarss' : false,\n  plugins: {\n    'postcss-import': { root: ctx.file.dirname },\n    cssnano: ctx.env === 'production' ? {} : false,\n  },\n})\n```\n\n\u003e ⚠️ If you want to set options via CLI, it's mandatory to reference `ctx.options` in `postcss.config.js`\n\n```bash\npostcss input.sss -p sugarss -o output.css -m\n```\n\n**postcss.config.js**\n\n```js\nmodule.exports = (ctx) =\u003e ({\n  map: ctx.options.map,\n  parser: ctx.options.parser,\n  plugins: {\n    'postcss-import': { root: ctx.file.dirname },\n    cssnano: ctx.env === 'production' ? {} : false,\n  },\n})\n```\n\n[npm]: https://img.shields.io/npm/v/postcss-cli.svg\n[npm-url]: https://npmjs.com/package/postcss-cli\n[node]: https://img.shields.io/node/v/postcss-cli.svg\n[node-url]: https://nodejs.org/\n[tests]: https://img.shields.io/github/workflow/status/postcss/postcss-cli/Node.js%20CI/master\n[tests-url]: https://github.com/postcss/postcss-cli/actions?query=branch%3Amaster\n[cover]: https://img.shields.io/coveralls/postcss/postcss-cli/master.svg\n[cover-url]: https://coveralls.io/github/postcss/postcss-cli\n[chat]: https://img.shields.io/gitter/room/postcss/postcss.svg\n[chat-url]: https://gitter.im/postcss/postcss\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostcss%2Fpostcss-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpostcss%2Fpostcss-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpostcss%2Fpostcss-cli/lists"}