{"id":20533092,"url":"https://github.com/css/csso-cli","last_synced_at":"2025-04-05T23:08:10.273Z","repository":{"id":17525752,"uuid":"81438629","full_name":"css/csso-cli","owner":"css","description":"Command line interface for CSSO","archived":false,"fork":false,"pushed_at":"2023-07-19T19:13:55.000Z","size":267,"stargazers_count":125,"open_issues_count":4,"forks_count":11,"subscribers_count":8,"default_branch":"master","last_synced_at":"2024-04-25T22:22:22.169Z","etag":null,"topics":["cli","css","csso","minifier"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/css.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}},"created_at":"2017-02-09T10:28:22.000Z","updated_at":"2024-04-07T22:46:13.000Z","dependencies_parsed_at":"2024-01-12T02:44:49.067Z","dependency_job_id":"abc1f70d-6032-4800-be91-059d927052c3","html_url":"https://github.com/css/csso-cli","commit_stats":{"total_commits":59,"total_committers":7,"mean_commits":8.428571428571429,"dds":"0.11864406779661019","last_synced_commit":"61de2d04d4791b044c975faa903dc0893f988ca0"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/css%2Fcsso-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/css%2Fcsso-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/css%2Fcsso-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/css%2Fcsso-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/css","download_url":"https://codeload.github.com/css/csso-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247411234,"owners_count":20934653,"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","css","csso","minifier"],"created_at":"2024-11-16T00:18:39.869Z","updated_at":"2025-04-05T23:08:10.256Z","avatar_url":"https://github.com/css.png","language":"JavaScript","readme":"[![NPM version](https://img.shields.io/npm/v/csso-cli.svg)](https://www.npmjs.com/package/csso-cli)\n[![Build Status](https://travis-ci.org/css/csso-cli.svg?branch=master)](https://travis-ci.org/css/csso-cli)\n[![Twitter](https://img.shields.io/badge/Twitter-@cssoptimizer-blue.svg)](https://twitter.com/cssoptimizer)\n\nCommand line interface for [CSSO](https://github.com/css/csso).\n\n\u003c!-- MarkdownTOC --\u003e\n\n- [Install](#install)\n- [Usage](#usage)\n  - [Source maps](#source-maps)\n  - [Usage data](#usage-data)\n  - [Debugging](#debugging)\n- [Related projects](#related-projects)\n- [License](#license)\n\n\u003c!-- /MarkdownTOC --\u003e\n\n## Install\n\n```\nnpm install -g csso-cli\n```\n\n## Usage\n\n```\nUsage:\n\n    csso [input] [options]\n\nOptions:\n\n        --comments \u003cvalue\u003e             Comments to keep: exclamation (default), first-exclamation or none\n        --debug [level]                Output intermediate state of CSS during a compression\n    -d, --declaration-list             Treat input as a declaration list\n        --force-media-merge            Enable unsafe merge of @media rules\n    -h, --help                         Output usage information\n    -i, --input \u003cfilename\u003e             Input file\n        --input-source-map \u003csource\u003e    Input source map: none, auto (default) or \u003cfilename\u003e\n    -o, --output \u003cfilename\u003e            Output file (result outputs to stdout if not set)\n        --no-restructure               Disable structural optimisations\n    -s, --source-map \u003cdestination\u003e     Generate source map: none (default), inline, file or \u003cfilename\u003e\n        --stat                         Output statistics in stderr\n    -u, --usage \u003cfilename\u003e             Usage data file\n    -v, --version                      Output version\n        --watch                        Watch source file for changes\n```\n\nSome examples:\n\n```\n\u003e csso in.css\n...output result in stdout...\n\n\u003e csso in.css --output out.css\n\n\u003e echo '.test { color: #ff0000; }' | csso\n.test{color:red}\n\n\u003e cat source1.css source2.css | csso | gzip -9 -c \u003e production.css.gz\n```\n\n### Source maps\n\nSource map doesn't generate by default. To generate map use `--source-map` CLI option, that can be:\n\n- `none` (default) – don't generate source map\n- `inline` – add source map into result CSS (via `/*# sourceMappingURL=application/json;base64,... */`)\n- `file` – write source map into file with same name as output file, but with `.map` extension (in this case `--output` option is required)\n- any other values treat as filename for generated source map\n\nExamples:\n\n```\n\u003e csso my.css --source-map inline\n\u003e csso my.css --output my.min.css --source-map file\n\u003e csso my.css --output my.min.css --source-map maps/my.min.map\n```\n\nUse `--input-source-map` option to specify input source map if needed. Possible values for option:\n\n- `auto` (default) - attempt to fetch input source map by follow steps:\n  - try to fetch inline map from input\n  - try to fetch source map filename from input and read its content\n  - (when `--input` is specified) check file with same name as input file but with `.map` extension exists and read its content\n- `none` - don't use input source map; actually it's using to disable `auto`-fetching\n- any other values treat as filename for input source map\n\nGenerally you shouldn't care about the input source map since defaults behaviour (`auto`) covers most use cases.\n\n\u003e NOTE: Input source map is using only if output source map is generating.\n\n### Usage data\n\n`CSSO` can use data about how `CSS` is using for better compression. File with this data (`JSON` format) can be set using `--usage` option. Read more about [Usage data](https://github.com/css/csso#usage-data) in [CSSO](https://github.com/css/csso) repository.\n\n### Debugging\n\nAll debug information outputs to `stderr`.\n\nTo get brief info about compression use `--stat` option.\n\n```\n\u003e echo '.test { color: #ff0000 }' | csso --stat \u003e/dev/null\nSource:     \u003cstdin\u003e\nOriginal:   25 bytes\nCompressed: 16 bytes (64.00%)\nSaving:     9 bytes (36.00%)\nTime:       7 ms\nMemory:     0.204 MB\n```\n\nTo get details about compression steps use `--debug` option.\n\n```\n\u003e echo '.test { color: green; color: #ff0000 } .foo { color: red }' | csso --debug\n## parsing done in 4 ms\n\nCompress block #1\n[0.000s] init\n[0.001s] clean\n[0.003s] replace\n[0.001s] prepare\n[0.001s] mergeAtrule\n[0.000s] initialMergeRuleset\n[0.000s] disjoinRuleset\n[0.000s] restructShorthand\n[0.001s] restructBlock\n[0.000s] mergeRuleset\n[0.000s] restructRuleset\n## compress done in 9 ms\n\n## generate done in 0 ms\n\n.foo,.test{color:red}\n```\n\nMore details are providing when `--debug` option has a number greater than `1`:\n\n```\n\u003e echo '.test { color: green; color: #ff0000 } .foo { color: red }' | csso --debug 2\n## parsing done in 4 ms\n\nCompress block #1\n[0.001s] init\n  .test{color:green;color:#ff0000}.foo{color:red}\n\n[0.001s] clean\n  .test{color:green;color:#ff0000}.foo{color:red}\n\n[0.004s] replace\n  .test{color:green;color:red}.foo{color:red}\n\n...\n\n[0.000s] mergeRuleset\n  .foo,.test{color:red}\n\n[0.000s] restructRuleset\n  .foo,.test{color:red}\n\n## compress done in 12 ms\n\n## generate done in 0 ms\n\n.foo,.test{color:red}\n```\n\nUsing `--debug` option adds stack trace to CSS parse error output. That can help to find out problem in parser.\n\n```\n\u003e echo '.a { color }' | csso --debug\n\nParse error \u003cstdin\u003e: Colon is expected\n    1 |.a { color }\n------------------^\n    2 |\n\n/usr/local/lib/node_modules/csso/lib/cli.js:243\n                throw e;\n                ^\n\nError: Colon is expected\n    at parseError (/usr/local/lib/node_modules/csso/lib/parser/index.js:54:17)\n    at eat (/usr/local/lib/node_modules/csso/lib/parser/index.js:88:5)\n    at getDeclaration (/usr/local/lib/node_modules/csso/lib/parser/index.js:394:5)\n    at getBlock (/usr/local/lib/node_modules/csso/lib/parser/index.js:380:27)\n    ...\n```\n\n## Related projects\n\n- [CSSO](https://github.com/css/csso) – CSS minifier itself\n- Gulp: [gulp-csso](https://github.com/ben-eb/gulp-csso)\n- Grunt: [grunt-csso](https://github.com/t32k/grunt-csso)\n- Broccoli: [broccoli-csso](https://github.com/sindresorhus/broccoli-csso)\n- PostCSS: [postcss-csso](https://github.com/lahmatiy/postcss-csso)\n- Webpack: [csso-loader](https://github.com/sandark7/csso-loader)\n\n## License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcss%2Fcsso-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcss%2Fcsso-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcss%2Fcsso-cli/lists"}