[英]Gulp: Did you forget to signal async completion error
I have had to recently upgrade to gulp 4 and I found this error:我最近不得不升级到 gulp 4,我发现了这个错误:
Did you forget to signal async completion?您是否忘记发出异步完成信号?
My gulpfile looks as follows:我的 gulpfile 如下所示:
(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. 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 v3 语法:
gulp.task("build", gulp.series("clean"), function(done) {
console.log("Started");
done();
});
gulp.task()
no longer takes 3 arguments, only two. gulp.task()
不再需要 3 个 arguments,只需两个。 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.其中
gulp.series
有两个(或更多)功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.