https://github.com/mynameiswhm/brotli-webpack-plugin
Prepare Brotli-compressed versions of assets to serve them with Content-Encoding: br
https://github.com/mynameiswhm/brotli-webpack-plugin
brotli webpack
Last synced: 6 months ago
JSON representation
Prepare Brotli-compressed versions of assets to serve them with Content-Encoding: br
- Host: GitHub
- URL: https://github.com/mynameiswhm/brotli-webpack-plugin
- Owner: mynameiswhm
- License: mit
- Created: 2016-07-29T10:49:23.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2021-07-30T11:34:37.000Z (about 4 years ago)
- Last Synced: 2025-03-28T09:08:32.548Z (7 months ago)
- Topics: brotli, webpack
- Language: JavaScript
- Size: 101 KB
- Stars: 214
- Watchers: 2
- Forks: 23
- Open Issues: 15
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# brotli plugin for webpack
[](https://greenkeeper.io/)
This plugin compresses assets with [Brotli](https://github.com/google/brotli) compression algorithm using [zlib](https://nodejs.org/api/zlib.html#zlib_zlib_brotlicompress_buffer_options_callback), [iltorb](https://github.com/MayhemYDG/iltorb#brotliencodeparams) or [brotli.js](https://github.com/foliojs/brotli.js) libraries for serving it with [ngx_brotli](https://github.com/google/ngx_brotli) or such.
## Installation
```
npm install --save-dev brotli-webpack-plugin
```## Usage
``` javascript
var BrotliPlugin = require('brotli-webpack-plugin');
module.exports = {
plugins: [
new BrotliPlugin({
asset: '[path].br[query]',
test: /\.(js|css|html|svg)$/,
threshold: 10240,
minRatio: 0.8
})
]
}
```Arguments:
* `asset`: The target asset name. Defaults to `'[path].br[query]'`.
* `[file]` is replaced with the original asset file name.
* `[fileWithoutExt]` is replaced with the file name minus its extension, e.g. the `style` of `style.css`.
* `[ext]` is replaced with the file name extension, e.g. the `css` of `style.css`.
* `[path]` is replaced with the path of the original asset.
* `[query]` is replaced with the query.
* `test`: All assets matching this RegExp are processed. Defaults to every asset.
* `threshold`: Only assets bigger than this size (in bytes) are processed. Defaults to `0`.
* `minRatio`: Only assets that compress better that this ratio are processed. Defaults to `0.8`.
* `deleteOriginalAssets`: remove original files that were compressed with brotli. Default: falseOptional arguments for Brotli (see [iltorb](https://github.com/MayhemYDG/iltorb#brotliencodeparams) doc for details):
* `mode`: Default: 0,
* `quality`: Default: 11,
* `lgwin`: Default: 22,
* `lgblock`: Default: 0,
* `size_hint`: Default: 0,
* `disable_literal_context_modeling`: Default: false## License
Heavily copy-pasted from [webpack/compression-webpack-plugin](https://github.com/webpack/compression-webpack-plugin) by [Tobias Koppers](https://github.com/sokra).
Licensed under [MIT](./LICENSE).