compression-webpack-plugin
Advanced tools
Comparing version 6.1.0 to 6.1.1
@@ -5,2 +5,9 @@ # Changelog | ||
### [6.1.1](https://github.com/webpack-contrib/compression-webpack-plugin/compare/v6.1.0...v6.1.1) (2020-11-12) | ||
### Bug Fixes | ||
* compatibility with child compilations ([5e3bb95](https://github.com/webpack-contrib/compression-webpack-plugin/commit/5e3bb9516499438e43dba69db6257b37da4fc5ef)) | ||
## [6.1.0](https://github.com/webpack-contrib/compression-webpack-plugin/compare/v6.0.5...v6.1.0) (2020-11-09) | ||
@@ -7,0 +14,0 @@ |
"use strict"; | ||
module.exports = require('./index').default; | ||
module.exports = require("./index").default; |
@@ -33,3 +33,3 @@ "use strict"; | ||
} = // eslint-disable-next-line global-require | ||
_webpack.default.sources || require('webpack-sources'); | ||
_webpack.default.sources || require("webpack-sources"); | ||
@@ -39,4 +39,4 @@ class CompressionPlugin { | ||
(0, _schemaUtils.validate)(_options.default, options, { | ||
name: 'Compression Plugin', | ||
baseDataPath: 'options' | ||
name: "Compression Plugin", | ||
baseDataPath: "options" | ||
}); | ||
@@ -48,5 +48,5 @@ const { | ||
cache = true, | ||
algorithm = 'gzip', | ||
algorithm = "gzip", | ||
compressionOptions = {}, | ||
filename = '[path][base].gz', | ||
filename = "[path][base].gz", | ||
threshold = 0, | ||
@@ -70,5 +70,5 @@ minRatio = 0.8, | ||
if (typeof this.algorithm === 'string') { | ||
if (typeof this.algorithm === "string") { | ||
// eslint-disable-next-line global-require | ||
const zlib = require('zlib'); | ||
const zlib = require("zlib"); | ||
@@ -167,3 +167,3 @@ this.algorithm = zlib[this.algorithm]; | ||
async compress(compilation, assets, CacheEngine, weakCache) { | ||
const assetNames = Object.keys(typeof assets === 'undefined' ? compilation.assets : assets).filter(assetName => // eslint-disable-next-line no-undefined | ||
const assetNames = Object.keys(typeof assets === "undefined" ? compilation.assets : assets).filter(assetName => // eslint-disable-next-line no-undefined | ||
_webpack.ModuleFilenameHelpers.matchObject.bind(undefined, this.options)(assetName)); | ||
@@ -193,5 +193,5 @@ | ||
if (typeof this.options.algorithm === 'function') { | ||
if (typeof this.options.algorithm === "function") { | ||
let filenameForRelatedName = this.options.filename; | ||
const index = filenameForRelatedName.lastIndexOf('?'); | ||
const index = filenameForRelatedName.lastIndexOf("?"); | ||
@@ -203,2 +203,4 @@ if (index >= 0) { | ||
relatedName = `${_path.default.extname(filenameForRelatedName).slice(1)}ed`; | ||
} else if (this.options.algorithm === "gzip") { | ||
relatedName = "gzipped"; | ||
} else { | ||
@@ -230,3 +232,3 @@ relatedName = `${this.options.algorithm}ed`; | ||
// eslint-disable-next-line global-require | ||
'compression-webpack-plugin': require('../package.json').version, | ||
"compression-webpack-plugin": require("../package.json").version, | ||
algorithm: this.algorithm, | ||
@@ -236,3 +238,3 @@ originalAlgorithm: this.options.algorithm, | ||
name, | ||
contentHash: _crypto.default.createHash('md4').update(input).digest('hex') | ||
contentHash: _crypto.default.createHash("md4").update(input).digest("hex") | ||
}; | ||
@@ -269,4 +271,4 @@ } else { | ||
const [, replacerFile] = match; | ||
const replacerQuery = match[2] || ''; | ||
const replacerFragment = match[3] || ''; | ||
const replacerQuery = match[2] || ""; | ||
const replacerFragment = match[3] || ""; | ||
@@ -286,7 +288,7 @@ const replacerExt = _path.default.extname(replacerFile); | ||
name: replacerName, | ||
ext: replacerExt || '' | ||
ext: replacerExt || "" | ||
}; | ||
let newFilename = this.options.filename; | ||
if (typeof newFilename === 'function') { | ||
if (typeof newFilename === "function") { | ||
newFilename = newFilename(pathData); | ||
@@ -305,3 +307,3 @@ } | ||
if (this.options.deleteOriginalAssets) { | ||
if (this.options.deleteOriginalAssets === 'keep-source-map') { | ||
if (this.options.deleteOriginalAssets === "keep-source-map") { | ||
// TODO `...` required only for webpack@4 | ||
@@ -336,3 +338,3 @@ const updatedAssetInfo = { ...info, | ||
static isWebpack4() { | ||
return _webpack.version[0] === '4'; | ||
return _webpack.version[0] === "4"; | ||
} | ||
@@ -345,3 +347,3 @@ | ||
// eslint-disable-next-line global-require | ||
const CacheEngine = require('./Webpack4Cache').default; | ||
const CacheEngine = require("./Webpack4Cache").default; | ||
@@ -355,7 +357,7 @@ const weakCache = new WeakMap(); | ||
// eslint-disable-next-line global-require | ||
const CacheEngine = require('./Webpack5Cache').default; | ||
const CacheEngine = require("./Webpack5Cache").default; | ||
compiler.hooks.compilation.tap(pluginName, compilation => { | ||
compiler.hooks.thisCompilation.tap(pluginName, compilation => { | ||
// eslint-disable-next-line global-require | ||
const Compilation = require('webpack/lib/Compilation'); | ||
const Compilation = require("webpack/lib/Compilation"); | ||
@@ -367,7 +369,7 @@ compilation.hooks.processAssets.tapPromise({ | ||
compilation.hooks.statsPrinter.tap(pluginName, stats => { | ||
stats.hooks.print.for('asset.info.compressed').tap('compression-webpack-plugin', (compressed, { | ||
stats.hooks.print.for("asset.info.compressed").tap("compression-webpack-plugin", (compressed, { | ||
green, | ||
formatFlag | ||
}) => // eslint-disable-next-line no-undefined | ||
compressed ? green(formatFlag('compressed')) : undefined); | ||
compressed ? green(formatFlag("compressed")) : undefined); | ||
}); | ||
@@ -374,0 +376,0 @@ }); |
@@ -26,3 +26,3 @@ "use strict"; | ||
return (0, _findCacheDir.default)({ | ||
name: 'compression-webpack-plugin' | ||
name: "compression-webpack-plugin" | ||
}) || _os.default.tmpdir(); | ||
@@ -29,0 +29,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
constructor(compilation) { | ||
this.cache = compilation.getCache('CompressionWebpackPlugin'); | ||
this.cache = compilation.getCache("CompressionWebpackPlugin"); | ||
} | ||
@@ -13,0 +13,0 @@ |
{ | ||
"name": "compression-webpack-plugin", | ||
"version": "6.1.0", | ||
"version": "6.1.1", | ||
"description": "Prepare compressed versions of assets to serve them with Content-Encoding", | ||
@@ -74,3 +74,4 @@ "license": "MIT", | ||
"standard-version": "^9.0.0", | ||
"webpack": "^5.4.0" | ||
"webpack": "^5.4.0", | ||
"workbox-webpack-plugin": "^6.0.0-alpha.3" | ||
}, | ||
@@ -77,0 +78,0 @@ "keywords": [ |
@@ -32,3 +32,3 @@ <div align="center"> | ||
```js | ||
const CompressionPlugin = require('compression-webpack-plugin'); | ||
const CompressionPlugin = require("compression-webpack-plugin"); | ||
@@ -133,3 +133,3 @@ module.exports = { | ||
new CompressionPlugin({ | ||
algorithm: 'gzip', | ||
algorithm: "gzip", | ||
}), | ||
@@ -264,3 +264,3 @@ ], | ||
new CompressionPlugin({ | ||
filename: '[path][base].gz', | ||
filename: "[path][base].gz", | ||
}), | ||
@@ -283,6 +283,6 @@ ], | ||
if (/\.svg$/.test(pathData.file)) { | ||
return 'assets/svg/[path][base].gz'; | ||
return "assets/svg/[path][base].gz"; | ||
} | ||
return 'assets/js/[path][base].gz'; | ||
return "assets/js/[path][base].gz"; | ||
}, | ||
@@ -362,3 +362,3 @@ }), | ||
new CompressionPlugin({ | ||
cache: 'path/to/cache', | ||
cache: "path/to/cache", | ||
}), | ||
@@ -386,3 +386,3 @@ ], | ||
```js | ||
const zopfli = require('@gfx/zopfli'); | ||
const zopfli = require("@gfx/zopfli"); | ||
@@ -414,3 +414,3 @@ module.exports = { | ||
```js | ||
const zlib = require('zlib'); | ||
const zlib = require("zlib"); | ||
@@ -420,4 +420,4 @@ module.exports = { | ||
new CompressionPlugin({ | ||
filename: '[path][base].br', | ||
algorithm: 'brotliCompress', | ||
filename: "[path][base].br", | ||
algorithm: "brotliCompress", | ||
test: /\.(js|css|html|svg)$/, | ||
@@ -445,3 +445,3 @@ compressionOptions: { | ||
```js | ||
const zlib = require('zlib'); | ||
const zlib = require("zlib"); | ||
@@ -451,4 +451,4 @@ module.exports = { | ||
new CompressionPlugin({ | ||
filename: '[path][base].gz', | ||
algorithm: 'gzip', | ||
filename: "[path][base].gz", | ||
algorithm: "gzip", | ||
test: /\.js$|\.css$|\.html$/, | ||
@@ -459,4 +459,4 @@ threshold: 10240, | ||
new CompressionPlugin({ | ||
filename: '[path][base].br', | ||
algorithm: 'brotliCompress', | ||
filename: "[path][base].br", | ||
algorithm: "brotliCompress", | ||
test: /\.(js|css|html|svg)$/, | ||
@@ -463,0 +463,0 @@ compressionOptions: { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
51644
495
25