-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fail the webpack build on lint errors #82
Comments
Same for me, does not work |
Any update on this? Mine also doesn't make the build fail. |
In order to fail the build, I had to modify the code that runs webpack (2.6) to output the compilation errors and throw an error to actually fail the build. I think the point is that webpack simply runs the build, and outputs the results. In my const util = require('util');
...
webpack(webpackConfig, function (err, stats) {
if (err) throw err;
if (stats.compilation.errors && stats.compilation.errors.length > 0) {
process.stdout.write(util.inspect(stats.compilation.errors));
throw new Error('One or more webpack errors occurred, failing build.')
}
}); |
Can you elaborate more on this solution, and how you incorporated this into package.json? I'm a webpack newbie but I need the build to fail on lint errors for our CI pipeline. |
@gregkopp for CI you can run it as a separate command. And for local development you can run it as "prestart" or something like "lint && build" |
In webpack 4, setting the emitErrors option to true was enough for me to fail the travis build. |
Is there a way to configure tslint-loader/webpack2 so that the entire webpack build will fail (return a non-0 exit code)? I tried with
emitErrors: true
andfailOnHint: true
but neither will fail the whole build.The text was updated successfully, but these errors were encountered: