依赖Gulp的任务无法正常工作 [英] Gulp dependant task not working properly

查看:278
本文介绍了依赖Gulp的任务无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个gulp任务,一个编译手写笔文件,另一个清理我的css文件,但我不明白为什么 only clean-style 在执行命令时运行:gulp style在终端上。

  gulp.task(clean-styles,function(done){ 
clean(config.css +** / *。css,done);
});
$ b $ gulp.task(styles,[clean-styles],function(){
return gulp.src(config.styles)
.pipe($。 plumber())
.pipe($。stylus())
.pipe(gulp.dest(config.css));
});

函数clean(path,done){
del(path,done);
}

我使用 Gulp版本3.9.0 在过去的多个项目中,我已经完成了这项工作,它似乎正在开展工作。



我不确定我在做什么错误。控制台中没有错误。



预期结果:
我希望清洁后运行样式 -styles 任务。



实际结果:只有干净样式运行。

 

感谢@ kombucha提高了头脑,这似乎是del包中的一个变化。 > gulp.task(clean-styles,function(done){
clean(config.css +** / *。css,done);
}) ;

gulp.task(styles,[clean-styles],function(){
return gulp.src(config.styles)
.pipe($ .plumber())
.pipe($。stylus())
.pipe(gulp.dest(config.css));
});

新的清理函数:

 函数clean(path,done){
del(path) .then(函数(路径){
console.log(清理:+路径);
done();
});
}


I have two gulp tasks, one to compile stylus files and the other is to clean my css files but I don't understand why only clean-styles run when I executed the command: gulp styles on the terminal.

gulp.task("clean-styles", function (done) {
    clean(config.css + "**/*.css", done);
});

gulp.task("styles", ["clean-styles"], function () {
    return gulp.src(config.styles)
        .pipe($.plumber())
        .pipe($.stylus())
        .pipe(gulp.dest(config.css));
});

function clean(path, done) {
    del(path, done);
}

I"m using Gulp version 3.9.0 I've done this on multiple project in the past and it seems to be working.

I'm not sure what I'm doing wrong. There are no errors in the console.

Expected Result: I expect styles to run after the clean-styles task.

Actual Result: Only clean-styles run.

解决方案

Thanks @kombucha for the heads up. It seems to be a change in the del package which caused this to no longer work.

gulp.task("clean-styles", function (done) {
    clean(config.css + "**/*.css", done);
});

gulp.task("styles", ["clean-styles"], function () {
    return gulp.src(config.styles)
        .pipe($.plumber())
        .pipe($.stylus())
        .pipe(gulp.dest(config.css));
});

New Clean function:

function clean(path, done) {
    del(path).then(function (paths) {
       console.log("Cleaning: " + paths);
       done();
    });
}

这篇关于依赖Gulp的任务无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆