gulp-uglify events.js unhandled 'error' event

自闭症网瘾萝莉.ら 提交于 2019-12-03 05:35:42

Following this helped:

  1. Install Gulp-util
  2. Import the Gulp-util by using the following statement: var gutil = require('gulp-util');
  3. Finally, when you are uglifying the code, attach the error handler like this: .pipe(uglify().on('error', gutil.log))

I was able to debug it. It was a syntax error in one of the minified files I was including.

The best way to understand errors in a Gulp pipeline is to use a helper module, such as pump. As explained in the Gulp documentation Why Use Pump? you can get the correct errors by wrapping your pipeline.

gulp.task('scripts', function(cb) {
    pump([
        gulp.src(paths.scripts),
        concat('all.js'),
        gulp.dest('public/assets/js'),
        rename('all.min.js'),
        uglify(),
        gulp.dest('public/assets/js'),
        livereload()
    ], cb);
});

Attaching an error handler to the UglifyJS part of the pipeline won't tell you about errors in the others, and it won't properly signal an error to Gulp's task running system.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!