2

In my web application I created gulpfile which compiles react files by using reactify with browserify. Here is how my bundle task looks:

var bundler = watchify(browserify({
    entries: config.paths.src.js.app,
    transform: [reactify, envify],
    debug: isDevelopment,
    cache: {}, packageCache: {}, fullPaths: true
}), watchify.args);

var bundle = function() {
    start();
    return bundler
        .bundle()
        .on('error', errorLog)
        .pipe(source(config.paths.build.appName))
        .pipe(gulpif(!isDevelopment, streamify(uglify())))
        .pipe(gulp.dest(config.paths.build.folder))
        .pipe(reload({stream:true}))
        .on('end', end);

};

function errorLog(error) {
    log('******  Start of Error  ******');
    gutil.log(gutil.colors.red(error.message));
    log('******  End of Error  ******');
}

The problem is that when error occurs my gulp crashes. Don't know how to handle it. Plumber doesn't work in that case. Any ideas?

niba
  • 2,821
  • 1
  • 19
  • 23

1 Answers1

0

This helped me

Try to add this.emit('end'); to errorLog

function errorLog(error) {
    log('******  Start of Error  ******');
    gutil.log(gutil.colors.red(error.message));
    log('******  End of Error  ******');
    this.emit('end');
}
Community
  • 1
  • 1
fkuril
  • 1
  • this.emit('end') ends the task which I dont want. I would like to display error and have still working browserify/watchify task in background. With this code I will have to manually re run task after each error. – niba Apr 21 '15 at 08:11