1.0.0-beta.2 • Published 8 years ago

@mapleinside/compression-webpack-plugin v1.0.0-beta.2

Weekly downloads
11
License
MIT
Repository
github
Last release
8 years ago

Compression Webpack Plugin

Codeship status for Compression Webpack Plugin

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

Usage

import CompressionPlugin from '@mapleinside/compression-webpack-plugin';

export default {
  plugins: [
	new CompressionPlugin({
	  asset: '{file}.gz',
	  algorithm: 'gzip',
	  regExp: /\.js$|\.html$/,
	  threshold: 10240,
	  minRatio: 0.8,
	})
  ]
}

Arguments:

  • asset: the target asset name. {file} is replaced with the original asset. Defaults to '{file}.gz';
  • algorithm: can be a function(buf, callback) or a string. For a string the algorithm is taken from zlib. Defaults to 'gzip';
  • regExp: all assets matching this RegExp are processed. Defaults to every asset;
  • threshold: only assets bigger than this size are processed. In bytes. Defaults to 0;
  • minRatio: only assets that compress better that this ratio are processed. Defaults to 0.8.

License

(The MIT License)

Copyright (c) 2015 Maple Inside

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.