Skip to content

Commit 445d548

Browse files
evilebottnawimichael-ciniawsky
authored andcommitted
fix(index): tapable deprecation warnings (webpack >= v4.0.0) (#234)
1 parent ee78c06 commit 445d548

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

src/index.js

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
5555
context = options.context;
5656
}
5757

58-
compiler.plugin('emit', (compilation, cb) => {
58+
const emit = (compilation, cb) => {
5959
debug('starting emit');
6060
const callback = () => {
6161
debug('finishing emit');
@@ -103,9 +103,9 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
103103
compilation.errors.push(err);
104104
})
105105
.then(() => callback());
106-
});
106+
};
107107

108-
compiler.plugin('after-emit', (compilation, cb) => {
108+
const afterEmit = (compilation, cb) => {
109109
debug('starting after-emit');
110110
const callback = () => {
111111
debug('finishing after-emit');
@@ -153,7 +153,17 @@ function CopyWebpackPlugin(patterns = [], options = {}) {
153153
}
154154

155155
callback();
156-
});
156+
};
157+
158+
if (compiler.hooks) {
159+
const plugin = { name: 'CopyPlugin' };
160+
161+
compiler.hooks.emit.tapAsync(plugin, emit);
162+
compiler.hooks.afterEmit.tapAsync(plugin, afterEmit);
163+
} else {
164+
compiler.plugin('emit', emit);
165+
compiler.plugin('after-emit', afterEmit);
166+
}
157167
};
158168

159169
return {

0 commit comments

Comments
 (0)