Skip to content

Commit

Permalink
fix(index): tapable deprecation warnings (webpack >= v4.0.0) (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored and michael-ciniawsky committed Mar 1, 2018
1 parent ee78c06 commit 445d548
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
context = options.context;
}

compiler.plugin('emit', (compilation, cb) => {
const emit = (compilation, cb) => {
debug('starting emit');
const callback = () => {
debug('finishing emit');
Expand Down Expand Up @@ -103,9 +103,9 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
compilation.errors.push(err);
})
.then(() => callback());
});
};

compiler.plugin('after-emit', (compilation, cb) => {
const afterEmit = (compilation, cb) => {
debug('starting after-emit');
const callback = () => {
debug('finishing after-emit');
Expand Down Expand Up @@ -153,7 +153,17 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
}

callback();
});
};

if (compiler.hooks) {
const plugin = { name: 'CopyPlugin' };

compiler.hooks.emit.tapAsync(plugin, emit);
compiler.hooks.afterEmit.tapAsync(plugin, afterEmit);
} else {
compiler.plugin('emit', emit);
compiler.plugin('after-emit', afterEmit);
}
};

return {
Expand Down

0 comments on commit 445d548

Please # to comment.