-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
22 lines (20 loc) · 808 Bytes
/
index.js
File metadata and controls
22 lines (20 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class ProcessUpdatedChunksPlugin {
constructor(processChunkCb) {
this.processChunkCb = processChunkCb;
this.chunkVersions = {};
}
apply(compiler) {
// Called after emitting assets to output directory
compiler.hooks.afterEmit.tap('AfterEmitPlugin', (compilation) => {
// Check which chunks have changed
const changedChunks = compilation.chunks.filter(chunk => {
const oldVersion = this.chunkVersions[chunk.name];
this.chunkVersions[chunk.name] = chunk.hash;
return chunk.hash !== oldVersion;
});
// Invoke callback on each chunk that has changed
changedChunks.forEach(this.processChunkCb);
});
}
}
module.exports = ProcessUpdatedChunksPlugin;