Development,  Gulp

Did you forget to signal async completion?

Gulp: did you forget to signal async completion?

Did you forget to signal async completion is a very common error for Gulp 4 users. Before Gulp 4, when we used Gulp 3.9.1 etc, everything works fine. We updated to version 4 and now what?
Well, Gulp changed a lot and we need to update our gulp files.

Let’s see one:

gulp.task('styles', function () {
	return gulp.src(['./parent-style.css', './style.css', './scss/*.scss'])
        .pipe(autoprefixer())
        .pipe(sass({outputStyle: 'compressed'}).on('error', sass.logError))
        .pipe(concat('style.min.css'))
        .pipe(gulp.dest('.'));
});

This is one task from one of my projects. It runs smoothly with Gulp 3.9.1. But when I upgraded to Gulp 4, I got this did you forget to signal async completion error while running `gulpfile.js`.

So, what to do? We must adjust our code a little bit, like that:

gulp.task('styles', function (done) {
	gulp.src([
		stylesheet_path + 'css/*.css',
		stylesheet_path + 'sass/*.scss',
	])
		.pipe(auto_prefix())
		.pipe(sass({outputStyle: 'compressed'}))
		.pipe(concat('hello-world.min.css'))
		.pipe(gulp.dest(assets_path + 'css/'));
	done();
});

Have fun!

Leave a Reply

Your email address will not be published. Required fields are marked *