{"id":23116165,"url":"https://github.com/web-alchemy/web-compressor","last_synced_at":"2025-04-04T01:24:46.750Z","repository":{"id":35946680,"uuid":"220415501","full_name":"web-alchemy/web-compressor","owner":"web-alchemy","description":"Utility for creating gzip and brotli pre-compressed files for a static web serving.","archived":false,"fork":false,"pushed_at":"2024-03-14T08:52:16.000Z","size":43,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-11T01:54:21.027Z","etag":null,"topics":["brotli","cli","compression","gzip","nodejs","optimization"],"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/web-alchemy.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}},"created_at":"2019-11-08T07:54:24.000Z","updated_at":"2023-10-16T10:37:44.000Z","dependencies_parsed_at":"2024-02-25T21:27:51.443Z","dependency_job_id":"32db63ac-0be0-49c9-9a97-34bd8ef59d24","html_url":"https://github.com/web-alchemy/web-compressor","commit_stats":null,"previous_names":[],"tags_count":27,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-alchemy%2Fweb-compressor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-alchemy%2Fweb-compressor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-alchemy%2Fweb-compressor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/web-alchemy%2Fweb-compressor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/web-alchemy","download_url":"https://codeload.github.com/web-alchemy/web-compressor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247104848,"owners_count":20884313,"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","compression","gzip","nodejs","optimization"],"created_at":"2024-12-17T04:13:38.752Z","updated_at":"2025-04-04T01:24:46.718Z","avatar_url":"https://github.com/web-alchemy.png","language":"JavaScript","readme":"# Web Compressor\n\nUtility for creating _gzip_ and _brotli_ pre-compressed files for a static web serving.\n\n## Using as a CLI\n\nBase example (run inside folder with static assets):\n```\nnpx @web-alchemy/web-compressor\n```\n\nExample with all parameters:\n```\nnpx @web-alchemy/web-compressor \\\n  --input=\u003cinput-folder\u003e \\\n  --output=\u003coutput-folder\u003e \\\n  --formats=gzip,brotli \\\n  --ext-white-list=.html,.css,.js,.json,.svg,.txt,.xml \\\n  --concurrency=4 \\\n  --file-size=4096\n```\n\n## Using as a module\n\n`npm install @web-alchemy/web-compressor`\n\n```javascript\nconst { compress, formats } = require('@web-alchemy/web-compressor');\n\ncompress({\n  input: '\u003cinput-folder\u003e',\n  output: '\u003coutput-folder\u003e',\n  formats: [formats.GZIP, formats.BROTLI]\n  extWhiteList: ['.html', '.css', '.js', '.json', '.svg', '.txt', '.xml'],\n  concurrency: 4,\n  fileSize: 4096\n}).then(() =\u003e {\n  // operation end\n}).catch(() =\u003e {\n  // operation error\n});\n```\n\n## Params Description\n\n| CLI Param | Module Param | Description | default value |\n| --- | --- | --- | --- |\n| `--from` (alias `--input`) | `from` (alias `input`) | Input folder | `process.cwd()` |\n| `--to` (alias `--output`) | `to` (alias `output`)| Output folder | `from` param value|\n| `--formats` | `formats` | Formats of output files | `['gzip', 'brotli']`|\n| `--ext-white-list` | `extWhiteList` | A list of extensions that will be used to filter the necessary files | `['.html', '.css', '.js', '.json', '.svg', '.txt', '.xml']` |\n| `--concurrency` | `concurrency` | number of parallel handlers | `os.cpus().length` |\n| `--file-size` | `fileSize` | File size treshold in bytes. Files smaller than this size will be ignored | `0` |\n\n\n## Enabling precompressed files serving in web servers\n\n- Nginx. [gzip](https://nginx.org/en/docs/http/ngx_http_gzip_static_module.html), [brotli](https://github.com/google/ngx_brotli)\n- [Caddy](https://caddyserver.com/docs/caddyfile/directives/file_server)\n- [H2O](https://h2o.examp1e.net/configure/file_directives.html#file.send-compressed)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-alchemy%2Fweb-compressor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fweb-alchemy%2Fweb-compressor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fweb-alchemy%2Fweb-compressor/lists"}