1 thought on “UglifyJS errors don’t bail the build with –bail

  1. I’ve created a workaround that will detect UglifyJs errors and exit the process with a non-zero status code:

    class DetectUglifyJsErrors {
      apply(compiler) {
        compiler.plugin('compilation', compilation => {
          compilation.plugin('optimize-chunk-assets', (chunks, callback) => {
            if (compilation.errors.length > 0) {
              compilation.errors.forEach(error => {
                console.error(`ERROR in ${error.message}`);
              });
              process.exit(1);
            }
            callback();
          });
        });
      }
    }
    

    This works for me and outputs the same message webpack would otherwise output.

Comments are closed.