Skip to content

Commit d6ccdc4

Browse files
aimichael-ciniawsky
authored andcommitted
fix(index): tapable deprecation warnings (webpack >= v4.0.0) (#100)
1 parent 75b19e2 commit d6ccdc4

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/index.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ class CompressionPlugin {
6464
}
6565

6666
apply(compiler) {
67-
compiler.plugin('emit', (compilation, callback) => {
67+
const emit = (compilation, callback) => {
6868
const { cache, threshold, minRatio, asset: assetName, filename, deleteOriginalAssets } = this.options;
6969
const cacheDir = cache === true ? findCacheDir({ name: 'compression-webpack-plugin' }) : cache;
7070

@@ -143,7 +143,14 @@ class CompressionPlugin {
143143
})
144144
.catch(cb);
145145
}, callback);
146-
});
146+
};
147+
148+
if (compiler.hooks) {
149+
const plugin = { name: 'CompressionPlugin' };
150+
compiler.hooks.emit.tapAsync(plugin, emit);
151+
} else {
152+
compiler.plugin('emit', emit);
153+
}
147154
}
148155

149156
compress(input) {

0 commit comments

Comments
 (0)