javascriptnode.jsgulplessgulp-less

Gulp ignoring dependency


I'm trying to figure out why my gulp tasks aren't running in the order i want them to, here is the code;

gulp.task('styles', ['clean-styles'], function () {
    log('Compiling Less --> CSS');

return gulp
    .src(config.less)
    .pipe($.less())
    .pipe($.autoprefixer({browsers: ['last 2 version', '> 5%']}))
    .pipe(gulp.dest(config.temp));
});

gulp.task('clean-styles', function (done) {
    var files = config.temp + '**/*.css';
    clean(files, done);
});

function clean(path, done) {
    log('Cleaning: ' + $.util.colors.blue(path));
    del(path, done);
}

When i run 'gulp styles' it only runs the 'clean-styles' function, when it should be running the 'styles' function after completing the clean task.

So in short, the question is;

Why is my 'styles' task being ignored when executed?

Thanks in advance


Solution

  • try to this:

    //An array of tasks to be executed and completed before your task will run.
    gulp.task('clean-styles', ['styles'], function() {
      // Do stuff
    });