├── .gitignore ├── CHANGELOG.md ├── README.md ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 2.0.0 2 | 3 | Relax the peer dependencies such that it can be used with Webpack 2 & 3. Note that this does NOT add *official* support 4 | for Webpack 2+ (2+ still shouldn't need this plugin). 5 | 6 | # 1.0.6 7 | - Add node engine requirement to package.json 8 | - Deprecate plugin, since this is default behaviour in Webpack 2+ 9 | 10 | # 1.0.5 11 | - Detect watch mode through the `run` hook instead of parsing CLI arguments, such that the detection works for all different watch methods (#4) 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED: This is default behaviour in Webpack 2.x, you probably don't need this plugin anymore. 2 | 3 | If you're using Webpack 2+ then you shouldn't need this plugin anymore. Under normal circumstances Webpack 4 | should already exit with a proper exit code. As such, this plugin does not officially support Webpack 2+. 5 | 6 | If you don't get the correct exit code with Webpack 2+ then this is most likely a bug in a plugin you're using, or 7 | you're running into a Webpack bug. In either case I strongly recommend to isolate the problem and file issues at the 8 | appropriate repositories. In the mean time you could try to use this plugin as a *temporary* workaround. 9 | 10 | # Description 11 | 12 | Webpack plugin that will make the process return status code 1 when it finishes with errors in single-run mode. 13 | 14 | ## Install 15 | ``` 16 | npm install webpack-fail-plugin --save-dev 17 | ``` 18 | 19 | ## Usage 20 | ```javascript 21 | var failPlugin = require('webpack-fail-plugin'); 22 | 23 | module.exports = { 24 | //config 25 | plugins: [ 26 | failPlugin 27 | ] 28 | } 29 | ``` 30 | 31 | Credits to [@happypoulp](https://github.com/happypoulp). 32 | 33 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | module.exports = function() { 2 | var isWatch = true; 3 | 4 | this.plugin("run", function(compiler, callback) { 5 | isWatch = false; 6 | callback.call(compiler); 7 | }); 8 | 9 | this.plugin("done", function(stats) { 10 | if (stats.compilation.errors && stats.compilation.errors.length && !isWatch) { 11 | process.on('beforeExit', function() { 12 | process.exit(1); 13 | }); 14 | } 15 | }); 16 | }; 17 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "webpack-fail-plugin", 3 | "version": "2.0.0", 4 | "description": "Webpack plugin that makes the process return an error code on failure", 5 | "main": "index.js", 6 | "engines": { 7 | "node": ">=0.11.12" 8 | }, 9 | "keywords": [ 10 | "webpack" 11 | ], 12 | "peerDependencies": { 13 | "webpack": "^1.9.11 || ^2 || ^3" 14 | }, 15 | "author": "Tiddo Langerak ", 16 | "license": "MIT", 17 | "repository": { 18 | "type": "git", 19 | "url": "git+https://github.com/TiddoLangerak/webpack-fail-plugin.git" 20 | }, 21 | "bugs": { 22 | "url": "https://github.com/TiddoLangerak/webpack-fail-plugin/issues" 23 | }, 24 | "homepage": "https://github.com/TiddoLangerak/webpack-fail-plugin#readme" 25 | } 26 | --------------------------------------------------------------------------------