@web-alchemy/web-compressor
v3.0.10
Published
Utility for creating _gzip_ and _brotli_ pre-compressed files for a static web serving.
Downloads
55
Maintainers
Readme
Web Compressor
Utility for creating gzip and brotli pre-compressed files for a static web serving.
Using as a CLI
Base example (run inside folder with static assets):
npx @web-alchemy/web-compressor
Example with all parameters:
npx @web-alchemy/web-compressor \
--input=<input-folder> \
--output=<output-folder> \
--formats=gzip,brotli \
--ext-white-list=.html,.css,.js,.json,.svg,.txt,.xml \
--concurrency=4 \
--file-size=4096
Using 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]
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
|