Skip to content

Commit

Permalink
fix: webpack 3 compability (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pooya Parsa committed Mar 26, 2018
1 parent 6f797cd commit ff24c14
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,22 @@ export default class WebpackBarPlugin extends webpack.ProgressPlugin {
apply(compiler) {
super.apply(compiler);

compiler.hooks.done.tap('webpackbar', () => {
logUpdate.clear();
if (compiler.hooks) {
// Webpack >= 4
compiler.hooks.done.tap('webpackbar', () => this.done());
} else {
// Webpack < 4
compiler.plugin('done', () => this.done());
}
}

if (this.options.profile) {
const stats = sharedState[this.options.name].profile.getStats();
printStats(stats);
}
});
done() {
logUpdate.clear();

if (this.options.profile) {
const stats = sharedState[this.options.name].profile.getStats();
printStats(stats);
}
}

updateProgress(percent, msg, details) {
Expand Down

0 comments on commit ff24c14

Please sign in to comment.