JSPM

razzle-plugin-compression

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 228
  • Score
    100M100P100Q87176F
  • License MIT

Razzle plugin to Compress bundle

Package Exports

  • razzle-plugin-compression

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (razzle-plugin-compression) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

npm version

razzle-plugin-compression

This package contains a plugin to compress assets with Razzle

Usage in Razzle Projects

yarn add razzle-plugin-compression --dev

create a razzle.config.js file in root directory of project (next to the package.json) and put this content inside it

Using the plugin with the default options

// razzle.config.js

module.exports = {
  plugins: ['compression'],
};

With custom options:

// razzle.config.js

module.exports = {
  plugins: [
    {
      name: 'compression',
      options: {
        brotli: true,
        gzip: true,
        compressionPlugin: {},
        brotliPlugin: {
          asset: "[path].br[query]",
          test: /\.(js|css|html|svg)$/,
          threshold: 10240,
          minRatio: 0.7
        }
      }
    }
  ]
};

Please remember that custom options will extends default options using Object.assign. Array WILL NOT BE EXTENDED OR CONCATED, it will override all default plugins.

Options

brotli: boolean (defaults: true)

Set brotli to false if you don't want to compress with brotli compression algorithm.

gzip: boolean (defaults: true)

Set gzip to false if you don't want to compress with gzip compression algorithm.

compressionPlugin: object

default: {}

See compression-webpack-plugin options to override configs.

brotliPlugin: object

default:

{
  asset: "[path].br[query]",
  test: /\.(js|css|html|svg)$/,
  threshold: 10240,
  minRatio: 0.7
}

See brotli-webpack-plugin options to override configs.