I have had to recently upgrade to gulp 4 and I found this error:
Did you forget to signal async completion?
My gulpfile looks as follows:
(function () {
"use strict";
const demoPath = "demo/node_modules/style";
var cleanCSS = require("gulp-clean-css");
const del = require("del");
const fs = require("fs");
var gulp = require("gulp");
var sass = require("gulp-sass");
var path = require("path");
var rename = require("gulp-rename");
gulp.task("clean", () => {
return del.sync([
"**.js", "!gulpfile.js"
]);
}, async function(done){
console.log("This is clean task!");
done();
});
function clean() {
return gulp.src("src/**/*.scss")
.pipe(sass())
.pipe(cleanCSS({}))
.pipe(rename({
extname: ".min.css"
}))
.pipe(gulp.dest("./dist"));
}
gulp.task("build", gulp.series("clean"), function(done) {
console.log("Started");
done();
});
}());
I read that with gulp 4 we would need to return a promise, a stream or callback etc. I did try to add the callback in the function and execute them but I still see the error.
Could anyone point me to a direction here?
Thanks for reading.
This code is gulp v3 syntax:
gulp.task("build", gulp.series("clean"), function(done) {
console.log("Started");
done();
});
gulp.task()
no longer takes 3 arguments, only two. So change to:
gulp.task("build", gulp.series("clean", function(done) {
console.log("Started");
done();
}));
where gulp.series
has the two (or more) functions inside it.