Skip to content

Commit ff24c14

Browse files
author
Pooya Parsa
committed
fix: webpack 3 compability (#1)
1 parent 6f797cd commit ff24c14

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

src/index.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,22 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
3535
apply(compiler) {
3636
super.apply(compiler);
3737

38-
compiler.hooks.done.tap('webpackbar', () => {
39-
logUpdate.clear();
38+
if (compiler.hooks) {
39+
// Webpack >= 4
40+
compiler.hooks.done.tap('webpackbar', () => this.done());
41+
} else {
42+
// Webpack < 4
43+
compiler.plugin('done', () => this.done());
44+
}
45+
}
4046

41-
if (this.options.profile) {
42-
const stats = sharedState[this.options.name].profile.getStats();
43-
printStats(stats);
44-
}
45-
});
47+
done() {
48+
logUpdate.clear();
49+
50+
if (this.options.profile) {
51+
const stats = sharedState[this.options.name].profile.getStats();
52+
printStats(stats);
53+
}
4654
}
4755

4856
updateProgress(percent, msg, details) {

0 commit comments

Comments
 (0)