Gulp dependant task not working properly

你离开我真会死。 提交于 2019-12-12 00:23:33

问题


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.


回答1:


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();
    });
}


来源:https://stackoverflow.com/questions/32712873/gulp-dependant-task-not-working-properly

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!