Socket
Socket
Sign inDemoInstall

html-compression-webpack-plugin

Package Overview
Dependencies
88
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.2.3 to 0.3.0

3

example/webpack.config.js

@@ -36,4 +36,3 @@ var path = require('path');

new HTMLCompressionPlugin({
deleteOriginals: true,
assetsRelativeOutputDirectory: './build',
deleteOriginalAssets: true,
minRatio: 0.9

@@ -40,0 +39,0 @@ })

@@ -11,3 +11,2 @@ /*

var path = require('path');
var del = require('del');

@@ -58,8 +57,3 @@ var RawSource = require("webpack-sources/lib/RawSource");

this.minRatio = options.hasOwnProperty('minRatio') ? options.minRatio : 0.8;
this.deleteOriginals = options.hasOwnProperty('deleteOriginals') ? options.deleteOriginals : false;
this.assetsRelativeOutputDirectory = options.hasOwnProperty('assetsRelativeOutputDirectory') ? options.assetsRelativeOutputDirectory : ''
this.originalAssetsPaths = new Array();
if(this.deleteOriginals === true && this.assetsRelativeOutputDirectory === ''){
throw new Error('Set relative output directory of assets when enabling deletion of original files');
}
this.deleteOriginalAssets = options.deleteOriginalAssets || false;
}

@@ -97,6 +91,6 @@

});
if(this.deleteOriginals === true){
this.originalAssetsPaths.push(path.join(__dirname, this.assetsRelativeOutputDirectory, file));
assets[newFile] = new RawSource(result);
if (this.deleteOriginalAssets) {
delete assets[file];
}
assets[newFile] = new RawSource(result);
callback();

@@ -133,6 +127,6 @@ }.bind(this));

});
if(this.deleteOriginals === true){
this.originalAssetsPaths.push(path.join(__dirname, this.assetsRelativeOutputDirectory, file));
compilation.assets[newFile] = new RawSource(result);
if (this.deleteOriginalAssets) {
delete compilation.assets[file];
}
compilation.assets[newFile] = new RawSource(result);
callback();

@@ -142,9 +136,2 @@ }.bind(this));

}.bind(this));
compiler.plugin('done', function(stats) {
if(this.deleteOriginals === true){
for (var i in this.originalAssetsPaths) {
del.sync([this.originalAssetsPaths[i]]);
}
}
}.bind(this));
};
};
{
"name": "html-compression-webpack-plugin",
"version": "0.2.3",
"version": "0.3.0",
"author": "Tobias Koppers @sokra & Tom De Backer @TomDeBacker",

@@ -5,0 +5,0 @@ "description": "Prepare compressed versions of assets to serve them with Content-Encoding.",

# HTML compression plugin for webpack
## Info
The `compression-webpack-plugin` didn't compress HTML files. This plugin aims to solve that. Also added an option to remove the original assets after compressing.
The `compression-webpack-plugin` didn't compress HTML files. This plugin aims to solve that.
## Usage
Credits to @sokra for the code from compression-webpack-plugin (https://github.com/webpack/compression-webpack-plugin)
Credits to @sokra for the code from compression-webpack-plugin (https://github.com/webpack/compression-webpack-plugin) and other that contributed to it.
Link to NPM: https://www.npmjs.com/package/html-compression-webpack-plugin

@@ -18,8 +18,7 @@

test: /.*\.(css|js)$/i,
deleteOriginals: true,
assetsRelativeOutputDirectory: '../build/client/assets',
asset: '[path].gz',
algorithm: 'gzip',
threshold: 0,
minRatio: 0.0
minRatio: 0.0,
deleteOriginalAssets: true
})

@@ -30,9 +29,7 @@ ]

Arguments:
* `asset`: The target asset name. `[file]` is replaced with the original asset. `[path]` is replaced with the path of the original asset and `[query]` with the query. Defaults to `"[path].gz[query]"`
* `assetsRelativeOutputDirectory`: The relative directory where your assets will be output to. Plugin will look in sub-folders for the original assets aswell.
* `algorithm`: Can be a `function(buf, callback)` or a string. For a string the algorithm is taken from `zlib` (or zopfli for `zopfli`). Defaults to `"gzip"`.
* `deleteOriginals`: All original assets which have been compressed will be deleted in the done phase. The stats after bundling will show the files emitted but they will be deleted. Defaults to `false`
* `deleteOriginalAssets`: Whether to delete the original assets or not. Defaults to `false`.
* `test`: All assets matching this RegExp are processed. Defaults to `/.*\.(js|css)$/i`

@@ -39,0 +36,0 @@ * `testHTML`: All assets matching this RegExp are processed. This will happen in the emit phase. Defaults to `/\.html$/`

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc