Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

compression-webpack-plugin

Package Overview
Dependencies
Maintainers
8
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

compression-webpack-plugin

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

  • 1.1.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by1.86%
Maintainers
8
Weekly downloads
 
Created

What is compression-webpack-plugin?

The compression-webpack-plugin is a plugin for Webpack that allows you to compress assets with various compression algorithms before they are output to the file system. This can help reduce the size of your assets, leading to faster load times for your web application.

What are compression-webpack-plugin's main functionalities?

Compression of assets

This feature allows you to compress files using gzip. The 'test' option is a RegExp that matches the files to compress.

const CompressionPlugin = require('compression-webpack-plugin');

module.exports = {
  plugins: [
    new CompressionPlugin({
      algorithm: 'gzip',
      test: /\.js(\?.*)?$/i,
    }),
  ],
};

Custom compression options

This feature allows you to use different compression algorithms like Brotli, and set custom compression options such as the compression level.

const CompressionPlugin = require('compression-webpack-plugin');

module.exports = {
  plugins: [
    new CompressionPlugin({
      algorithm: 'brotliCompress',
      test: /\.js(\?.*)?$/i,
      compressionOptions: { level: 11 },
    }),
  ],
};

Asset filtering

This feature allows you to exclude certain assets from being compressed by using the 'exclude' option.

const CompressionPlugin = require('compression-webpack-plugin');

module.exports = {
  plugins: [
    new CompressionPlugin({
      test: /\.js(\?.*)?$/i,
      exclude: /node_modules/,
    }),
  ],
};

Threshold and minRatio settings

This feature allows you to only compress assets that are larger than a certain size (threshold) and only if the compression ratio is below a certain value (minRatio).

const CompressionPlugin = require('compression-webpack-plugin');

module.exports = {
  plugins: [
    new CompressionPlugin({
      test: /\.js(\?.*)?$/i,
      threshold: 10240,
      minRatio: 0.8
    }),
  ],
};

Other packages similar to compression-webpack-plugin

FAQs

Package last updated on 16 Feb 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc