Reputation: 1663
I write gulpfile.js
like:
...
gulp.task('styles',function(){
gulp.src('./src/sass/*.scss')
.pipe(sass())
.pipe(autoprefixer('last 2 version'))
.pipe(concat('tmp.css'))
.pipe(gulp.dest('./build/css'))
.pipe(notify('Styles task complete'))
})
gulp.task('css',['styles'],function(cb){
del(['./build/css/tmp.css'],cb)
})
.....
When I run gulp css
,the styles
task will first be execute, so ./build/css/tmp.css
will be removed.
But the ./build/css/tmp.css
is still exist.That is mean,when the css
task be executed,the styles
task has not yet be execute.
Why the dependences not work? and how can I make sure the './build/css/tmp.css'
has exist before the css
task be executed?
Upvotes: 1
Views: 47
Reputation: 8091
I have seen this issue intermittently working without the returns in dependencies.
You need to return the actual task so gulp knows when it's complete.
So this should become :
gulp.task('styles',function(){
return gulp.src('./src/sass/*.scss')
.pipe(sass())
.pipe(autoprefixer('last 2 version'))
.pipe(concat('tmp.css'))
.pipe(gulp.dest('./build/css'))
.pipe(notify('Styles task complete'))
});
gulp.task('css',['styles'],function(cb){
del(['./build/css/tmp.css'],cb)
})
This will then wait for styles to complete (as a dependency returned) and then continue.
Upvotes: 1