@web-alchemy/web-compressor
v3.1.2
Published
Utility for creating _gzip_, _brotli_ and _zstd_ pre-compressed files for a static web serving.
Maintainers
Readme
Web Compressor
Utility for creating gzip, brotli and zstd pre-compressed files for a static web serving.
Using as a CLI
Base example (run inside folder with static assets):
npx @web-alchemy/web-compressorExample with all parameters:
npx @web-alchemy/web-compressor \
--input=<input-folder> \
--output=<output-folder> \
--formats=gzip,brotli,zstd \
--ext-white-list=.html,.css,.js,.json,.svg,.txt,.xml \
--concurrency=4 \
--file-size=4096Using as a module
npm install @web-alchemy/web-compressor
const { compress, formats } = require('@web-alchemy/web-compressor');
compress({
input: '<input-folder>',
output: '<output-folder>',
formats: [formats.GZIP, formats.BROTLI, formats.ZSTD]
extWhiteList: ['.html', '.css', '.js', '.json', '.svg', '.txt', '.xml'],
concurrency: 4,
fileSize: 4096
}).then(() => {
// operation end
}).catch(() => {
// operation error
});Params Description
| CLI Param | Module Param | Description | default value |
| --- | --- | --- | --- |
| --from (alias --input) | from (alias input) | Input folder | process.cwd() |
| --to (alias --output) | to (alias output) | Output folder | from param value |
| --formats | formats | Formats of output files | ['gzip', 'brotli']|
| --ext-white-list | extWhiteList | A list of extensions that will be used to filter the necessary files | ['.html', '.css', '.js', '.json', '.svg', '.txt', '.xml'] |
| --concurrency | concurrency | number of parallel handlers | os.cpus().length |
| --file-size | fileSize | File size treshold in bytes. Files smaller than this size will be ignored | 0 |
