When compiling a project in webpack using the --watch option, if the project has an error for example in the less compiler I see that error in the output. Once I correct the error webpack recompiles and all is well.
However if there are multiple errors in the file and I only fix one of them, when webpack re-compiles the code it does not show the new error message, in fact the console does not update at all.
For example:
less file has two errors and save the filewebpack --watch attempts to compile the file and fails, showing the first errorwebpack does not show the second errorHow can I tell webpack to show the error of the updated build after if fails for a second time?
It appears that this option is not available on webpack cli but you can easily create a plugin to listen for build events and output any errors, i.e.:
const ConsoleNotifierPlugin = function () {}
ConsoleNotifierPlugin.prototype.compilationDone = (stats) => {
const log = (error) => {
console.log(error.error.toString())
}
stats.compilation.errors.forEach(log)
}
ConsoleNotifierPlugin.prototype.apply = function (compiler) {
compiler.plugin('done', this.compilationDone.bind(this))
}
Then just add it to the plugins:
...
plugins: [new ConsoleNotifierPlugin()]
...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With