{"id":19436017,"url":"https://github.com/ralscha/bread-compressor-cli","last_synced_at":"2026-03-13T20:34:11.996Z","repository":{"id":143731480,"uuid":"123455894","full_name":"ralscha/bread-compressor-cli","owner":"ralscha","description":"Brotli and Gzip compress command line tool","archived":false,"fork":false,"pushed_at":"2025-03-26T08:58:21.000Z","size":204,"stargazers_count":14,"open_issues_count":1,"forks_count":4,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-03T11:36:42.013Z","etag":null,"topics":["brotli","cli","gzip","npm","precompress-command","static-resources","zopfli"],"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/ralscha.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2018-03-01T15:44:57.000Z","updated_at":"2025-03-26T08:58:25.000Z","dependencies_parsed_at":"2023-11-23T20:06:26.122Z","dependency_job_id":"7d91bbbb-21e4-4164-a946-b1802f84b1fc","html_url":"https://github.com/ralscha/bread-compressor-cli","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fbread-compressor-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fbread-compressor-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fbread-compressor-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ralscha%2Fbread-compressor-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ralscha","download_url":"https://codeload.github.com/ralscha/bread-compressor-cli/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250712884,"owners_count":21475093,"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":["brotli","cli","gzip","npm","precompress-command","static-resources","zopfli"],"created_at":"2024-11-10T15:09:02.791Z","updated_at":"2026-03-13T20:34:06.944Z","avatar_url":"https://github.com/ralscha.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Command line tool for compressing static resources with brotli and gzip. \r\n\r\n\r\n## Installation\r\n```\r\nnpm install bread-compressor-cli -D\r\n```\r\n\r\n\r\n## Usage\r\nCall the tool with npx\r\n```\r\nnpx bread-compressor dist\r\n```\r\n\r\nor insert a script in package.json\r\n```\r\n \"scripts\": {\r\n\t\"compress\": \"bread-compressor dist\"\r\n  },\r\n```\r\nand run it with npm\r\n```\r\nnpm run compress\r\n```\r\n\r\n\r\n#### Ignores\r\nThe tool ignores by default files with the suffix .gz, .br, .zst, .zip, .png, .jpeg, .jpg, .woff and .woff2.\r\nYou can disable this with the `-n` option and all files will be compressed.\r\n```\r\nbread-compressor -n dist\r\n```\r\n\r\n\r\n#### Glob\r\nYou can specify multiple paths in one call, the tool processes all files that match the globs.\r\n\r\nCompress files in *dist* and *www* folder and subfolders.\r\n``` \r\nbread-compressor dist www\r\n```\r\nThese globs are shortcuts for dist/\\*\\*/* and www/\\*\\*/*\r\n\r\n\r\nOnly compress *.css*, *.js* and *.html* files in the *dist* folder and subfolders.\r\n``` \r\nbread-compressor \"dist/**/*.css\" \"dist/**/*.js\" \"dist/**/*.html\"\r\n```\r\n\r\nCompress files in *dist* folder and subfolder, except *big.txt* and files ending with *.pdf*\r\n```\r\nbread-compressor dist \"!big.txt\" \"!*.pdf\"\r\n```\r\n\r\nSee the globby project site for more information about the supported glob patterns:    \r\nhttps://github.com/sindresorhus/globby\r\n\r\n\r\n#### Algorithm\r\nThe tool compresses the files by default with gzip and brotli. You can set the `-a` option \r\nto specify which algorithm to use. The -a options expects a comma separated list of algorithms.\r\n\r\nCompress with gzip only\r\n```\r\nbread-compressor -a gzip dist\r\n```\r\n\r\nCompress with brotli and zstandard\r\n```\r\nbread-compressor -a brotli,zstd dist\r\n```\r\n\r\n\r\n#### Statistics\r\nThe tool prints out a summary with the `-s` option. \r\n\r\n```\r\nbread-compressor -s dist\r\n```\r\n\r\n```                                    \r\ngzip                                                              \r\nNumber of Files  : 7                                              \r\nUncompressed     : 53,467 Bytes                                   \r\nCompressed       : 11,799 Bytes                                   \r\nCompression Ratio: 22.07%                                         \r\nCompression Time : 4.341 s                                        \r\n                                                                  \r\nbrotli                                                            \r\nNumber of Files  : 7                                              \r\nUncompressed     : 53,467 Bytes                                   \r\nCompressed       : 9,830 Bytes                                    \r\nCompression Ratio: 18.39%                                         \r\nCompression Time : 0.562 s                                        \r\n```\r\n\r\n\r\n#### Zopfli options\r\nYou can pass options to the underlying zopfli library. \r\n\r\n```\r\nbread-compressor --zopfli-numiterations=15 --zopfli-blocksplittinglast=true dist\r\n```\r\n\r\nSee the project site of [@gfx/zopfli](https://github.com/gfx/universal-zopfli-js) for more information.\r\n\r\n\r\n#### Brotli options\r\nYou can pass options to the underlying brotli library. \r\n\r\n```\r\nbread-compressor --brotli-mode=0 --brotli-quality=10 --brotli-lgwin=21 dist\r\n```\r\n\r\nSee the project site of [brotli](https://www.npmjs.com/package/brotli) for more information.\r\n\r\n#### Zstandard options\r\nYou can pass options to the underlying zstd-wasm library. \r\n\r\n```\r\nbread-compressor --zstd-level=10 -a zstd dist\r\n```\r\n\r\nSee the project site of [zstd-wasm](https://github.com/bokuweb/zstd-wasm)\r\n\r\n#### Concurrent tasks\r\nBy default, two tasks will run concurrently. You can change this number with the `-l` option\r\n\r\nRun 4 compression tasks concurrently.\r\n```\r\nbread-compressor -l 4 dist\r\n```\r\n\r\n\r\n## Internals\r\nThis tool depends on [@gfx/zopfli](https://github.com/gfx/universal-zopfli-js) and [node-zopfli-es](https://github.com/jaeh/node-zopfli-es) for GZip compression, \r\n[brotli](https://www.npmjs.com/package/brotli) for Brotli compression and [zstd-wasm](https://github.com/bokuweb/zstd-wasm) \r\nfor Zstandard compression.\r\n\r\nOther dependecies are [commander](https://github.com/tj/commander.js) for command line argument parsing, [chalk](https://github.com/chalk/chalk) for terminal output styling,  [globby](https://github.com/sindresorhus/globby) for glob matching and [promise-limit](https://github.com/featurist/promise-limit) for limiting concurrent tasks. \r\n\r\n\r\n\r\n## Browser Support for Brotli\r\n\r\nCurrent versions of the major browsers send `br` in the `Accept-Encoding` header when the request is sent over TLS\r\n\r\nSupport introduced in version ...\r\n\r\n  * Edge 15\r\n  * Firefox 44\r\n  * Chrome 50\r\n  * Safari 11\r\n\r\n\r\n## Browser Support for Zstandard\r\n\r\n  * Chrome 123\r\n\r\nhttps://caniuse.com/zstd\r\n\r\n\r\n## Server support\r\n\r\nTo take advantage of precompressed resources you need a server that is able to understand the `Accept-Encoding` header and serve files ending with `.gz` and `.br` accordingly.\r\n\r\n#### Nginx \r\nNginx supports Gzip compressed files out of the box with the `gzip_static` directive. \r\n\r\nAdd this to a `http`, `server` or `location` section and Nginx will automatically search for files ending with .gz when the request contains an `Accept-Encoding` header with the value `gzip`. \r\n```\r\ngzip_static  on;  \r\n```\r\nSee the [documentation](http://nginx.org/en/docs/http/ngx_http_gzip_static_module.html) for more information.\r\n\r\nTo enable Brotli support you either \r\n  * build the [ngx_brotli](https://github.com/google/ngx_brotli) from source:          \r\n    https://www.majlovesreg.one/adding-brotli-to-a-built-nginx-instance\r\n  * or install a pre-built Nginx from ppa with the brotli module included:  \r\n    https://gablaxian.com/blog/brotli-compression\r\n  * or use the approach described in this blog post that works without the brotli module:    \r\n    https://siipo.la/blog/poor-mans-brotli-serving-brotli-files-without-nginx-brotli-module\r\n\r\n\r\n#### Apache HTTP\r\nhttps://css-tricks.com/brotli-static-compression/     \r\nhttps://blog.desgrange.net/post/2017/04/10/pre-compression-with-gzip-and-brotli-in-apache.html\r\n\r\n\r\n#### LightSpeed\r\nSupport for Brotli introduced in version [5.2](https://www.litespeedtech.com/products/litespeed-web-server/release-log)\r\n\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralscha%2Fbread-compressor-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fralscha%2Fbread-compressor-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fralscha%2Fbread-compressor-cli/lists"}