# brotli-webpack-plugin

> Prepare Brotli-compressed versions of assets to serve them with Content-Encoding: br

Latest version **1.1.0** (published 2019-01-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install brotli-webpack-plugin
pnpm add brotli-webpack-plugin
yarn add brotli-webpack-plugin
bun add brotli-webpack-plugin
```

## Health

**Score 23/100 (F)** — status: abandoned.

Positive: has types package; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.0 |
| Published | 2019-01-26 |
| First published | 2016-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | separate (@types/brotli-webpack-plugin) |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 391.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 213 |
| Author | Ilia Saulenko |
| Maintainers | mynameiswhm |

## Links

- npm: https://www.npmjs.com/package/brotli-webpack-plugin
- Repository: https://github.com/mynameiswhm/brotli-webpack-plugin
- Issues: https://github.com/mynameiswhm/brotli-webpack-plugin/issues
- npm.io page: https://npm.io/package/brotli-webpack-plugin

## Dependencies (4)

- [async](https://npm.io/package/async.md) ~2.6.0
- [brotli](https://npm.io/package/brotli.md) ^1.3.1
- [iltorb](https://npm.io/package/iltorb.md) ^2.0.1
- [webpack-sources](https://npm.io/package/webpack-sources.md) ^1.0.2

## Recent versions

- 1.1.0 (latest) — 2019-01-26
- 0.3.0-beta.0 (next) — 2017-04-02
- 1.0.0 — 2018-05-10
- 0.5.0 — 2017-11-10
- 0.4.3 — 2017-10-20
- 0.4.2 — 2017-10-20
- 0.4.1 — 2017-08-30
- 0.4.0 — 2017-07-19
- 0.3.0 — 2017-04-05
- 0.2.0 — 2017-01-23
- 0.1.2 — 2016-12-13
- 0.1.1 — 2016-07-30
- 0.1.0 — 2016-07-29

## README

# brotli plugin for webpack

[![Greenkeeper badge](https://badges.greenkeeper.io/mynameiswhm/brotli-webpack-plugin.svg)](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: false

Optional 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).

---
_Source: https://npm.io/package/brotli-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
