Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including brotli-webpack-plugin with all npm packages installed. Try it out:

var brotliWebpackPlugin = require("brotli-webpack-plugin")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

brotli-webpack-plugin v1.1.0

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

brotli plugin for webpack

Greenkeeper badge

This plugin compresses assets with Brotli compression algorithm using zlib, iltorb or brotli.js libraries for serving it with ngx_brotli or such.


npm install --save-dev brotli-webpack-plugin


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


  • 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 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


Heavily copy-pasted from webpack/compression-webpack-plugin by Tobias Koppers.

Licensed under MIT.

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free