Skip to content
This repository has been archived by the owner on Nov 11, 2022. It is now read-only.

Commit

Permalink
fix(index): skip not changed chunk files in watch mode (fix webpack-c…
Browse files Browse the repository at this point in the history
  • Loading branch information
akosyakov committed Oct 4, 2019
1 parent af883d8 commit 6b6a200
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ class CompressionPlugin {
constructor(options = {}) {
validateOptions(schema, options, 'Compression Plugin');

this.chunkVersions = {};

const {
test,
include,
Expand Down Expand Up @@ -85,12 +87,27 @@ class CompressionPlugin {
? findCacheDir({ name: 'compression-webpack-plugin' }) ||
os.tmpdir()
: cache;

const skipFiles = {};
for (const chunk of compilation.chunks) {
const oldVersion = this.chunkVersions[chunk.name];
this.chunkVersions[chunk.name] = chunk.hash;
if (chunk.hash === oldVersion) {
for (const file of chunk.files) {
skipFiles[file] = true;
}
}
}

const { assets } = compilation;

// eslint-disable-next-line consistent-return
async.forEach(
Object.keys(assets),
(file, cb) => {
if (skipFiles[file]) {
return cb();
}
if (!ModuleFilenameHelpers.matchObject(this.options, file)) {
return cb();
}
Expand Down

0 comments on commit 6b6a200

Please sign in to comment.