This is a known issue when using lazypipe with gulp 4, and it will not be fixed in the near future. Quote from this problem:
OverZealous commented on December 20, 2015.
I'm not going to do lasippipp on gulp 4 at the moment.
As far as I can tell, this problem is caused by the fact that gulp 4 uses async-done , which has this to say about its thread support:
Note. Only actual streams are supported, not faux streams; Therefore, event-stream modules are not supported.
When you use lazypipe() as the last channel, you get a stream that does not have a lot of properties that you usually use when working with streams in gulp. You can see it yourself by registering the threads:
// console output shows lots of properties console.log(gulp.src(src('js/**/*.js')) .pipe(plugins.concat('cat.js')) .pipe(gulp.dest(dest))); // console output shows much fewer properties console.log(gulp.src(src('js/**/*.js')) .pipe(buildFiles()));
This is probably the reason why gulp considers the second thread to be a "fake thread" and does not detect when the thread is finished.
Your only option at the moment is a kind of workaround. The easiest workaround (which does not require additional packages) is to simply add the cb callback function to your task and listen for the 'end' event:
gulp.task('build', function(cb) { var dest = 'build'; var buildFiles = lazypipe() .pipe(plugins.concat, 'cat.js') .pipe(gulp.dest, dest); gulp.src(src('js/**/*.js')) .pipe(buildFiles()) .on('end', cb); });
Alternatively, adding any .pipe() after buildFiles() should fix this, even one that actually does nothing gutil.noop()
var gutil = require('gulp-util'); gulp.task('build', function() { var dest = 'build'; var buildFiles = lazypipe() .pipe(plugins.concat, 'cat.js') .pipe(gulp.dest, dest); return gulp.src(src('js/**/*.js')) .pipe(buildFiles()) .pipe(gutil.noop()); });