New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

html-webpack-brotli-plugin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

html-webpack-brotli-plugin

Add .br suffix to index.html file's script that generated by html-webpack-plugin

latest
Source
npmnpm
Version
0.0.4
Version published
Weekly downloads
2
-75%
Maintainers
1
Weekly downloads
 
Created
Source

Brotli extension for the HTML Webpack Plugin

npm version Dependency Status Build status js-semistandard-style

Add .br suffix to index.html file's script that generated by html-webpack-plugin.

This is an extension plugin for the webpack plugin html-webpack-plugin - a plugin that simplifies the creation of HTML files to serve your webpack bundles.

Installation

Install the plugin with npm:

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

Basic Usage

Require the plugin in your webpack config:

var HtmlWebpackBrotliPlugin = require("html-webpack-brotli-plugin");

Add the plugin to your webpack config as follows:

plugins: [
  new HtmlWebpackPlugin(),
  new BrotliPlugin({
    asset: "[path].br[query]",
    test: /\.(js|css|html|svg)$/,
    threshold: 10240,
    minRatio: 0.8
  }), // brotli plugin will generate the xxx.js.br file
  new HtmlWebpackBrotliPlugin()
];

The above configuration will actually do nothing due to the configuration defaults.

As soon as you set addBrotliExtension to true, the file name of the index.html's script tag will always be added .br suffix. Eg: xxx.js.br This is very useful if you are using brotli-webpack-plugin.

plugins: [
  new HtmlWebpackPlugin({
    addBrotliExtension: true
  }),
  new BrotliPlugin({
    asset: "[path].br[query]",
    test: /\.(js|css|html|svg)$/,
    threshold: 10240,
    minRatio: 0.8
  }), // brotli plugin will generate the xxx.js.br file
  new HtmlWebpackBrotliPlugin()
];

Even if you generate multiple files make sure that you add the HtmlWebpackBrotliPlugin only once:

plugins: [
  new HtmlWebpackPlugin({
    addBrotliExtension: true
  }),
  new HtmlWebpackPlugin({
    addBrotliExtension: true,
    filename: "demo.html"
  }),
  new HtmlWebpackPlugin({
    addBrotliExtension: false,
    filename: "test.html"
  }),
  new BrotliPlugin({
    asset: "[path].br[query]",
    test: /\.(js|css|html|svg)$/,
    threshold: 10240,
    minRatio: 0.8
  }), // brotli plugin will generate the xxx.js.br file
  new HtmlWebpackBrotliPlugin()
];

Keywords

webpack

FAQs

Package last updated on 02 Oct 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts