我有一个Gulp 3文件,我试图升级到Gulp 4。当我这样做时,一些任务工作,其他人不工作。我得到的三个错误如下:
清爽型:
gulp.task('clean-styles', function (done) {
var files = config.temp + '**/*.css';
clean(files, done);
});
[23:47:05] The following tasks did not complete: clean-styles
[23:47:05] Did you forget to signal async completion?
scss观察程序:
gulp.task('scss-watcher', function () {
gulp.watch([config.scss], ['styles']);
});
[23:51:27] 'scss-watcher' errored after 2.46 ms
[23:51:27] Error: watching ./src/client/styles/styles.scss: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
styles:(如果我删除clean-styles系列,这将起作用)
gulp.task('styles', gulp.series('clean-styles', function () {
log('Compiling SCSS --> CSS');
return gulp
.src(config.scss)
.pipe($.scss())
.pipe($.autoprefixer({ browsers: ['last 2 versions', '> 5%'] }))
.pipe(gulp.dest(config.temp));
}));
[23:52:42] The following tasks did not complete: styles, clean-styles
[23:52:42] Did you forget to signal async completion?
(作品)
gulp.task('vet', function () {
log('Analyzing source with ESLint');
return gulp
.src(config.js)
.pipe($.if(args.verbose, $.print()))
.pipe($.eslint())
.pipe($.eslint.format())
.pipe($.eslint.failOnError());
});
功能:
function clean(path, done) {
log('Cleaning: ' + $.util.colors.blue(path));
del(path, done);
}
function log(msg) {
if (typeof(msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
}
else {
$.util.log($.util.colors.blue(msg));
}
}
我一定是错过了什么。有人能告诉我我错过了什么吗?
2条答案
按热度按时间a6b3iqyw1#
clean-styles
del
doesn't take a callback function. It returns aPromise
that you have to return in your task:scss-watcher
gulp.watch()
doesn't support arrays of task names anymore. You have to pass it a function,gulp.series()
orgulp.parallel()
:styles
Should work with the changes to
clean-styles
above.mdfafbf12#
朋友们,这是解决此问题的方法:
我们需要调用回调函数(Task和Anonimous