I am writing a plugin for webpack which starts good-fence in the background using EXECA. After the job is over I add errors to compilation.errors array. As execa runs in separate process errors added after the webpack compilation process finished. As a result, webpack-dev-server reloads the page with no errors. I had to manually reload the page to see the errors. Is there a way to force webpack-dev-server to reload?
const execa = require('execa');
class GoodFencesWebpackPlugin {
apply(compiler) {
let subprocess = null;
compiler.hooks.make.tap('GoodFencesWebpackPlugin', async (compilation) => {
const logger = compiler.getInfrastructureLogger('GoodFencesWebpackPlugin');
if (subprocess) {
subprocess.kill();
subprocess = null;
}
subprocess = execa('good-fences');
try {
await subprocess;
}
catch (err) {
logger.error("\x1b[31m", err.stderr);
compilation.errors.push(err.stderr);
}
subprocess = null;
})
}
}
module.exports = GoodFencesWebpackPlugin;