in the snippet like this:
gulp.task \"coffee\", ->
gulp.src(\"src/server/**/*.coffee\")
.pipe(coffee {bare: true}).on(\"error\",gutil.log)
Simply make coffee depend on clean, and develop depend on coffee:
gulp.task('coffee', ['clean'], function(){...});
gulp.task('develop', ['coffee'], function(){...});
Dispatch is now serial: clean → coffee → develop. Note that clean's implementation and coffee's implementation must accept a callback, "so the engine knows when it'll be done":
gulp.task('clean', function(callback){
del(['dist/*'], callback);
});
In conclusion, below is a simple gulp pattern for a synchronous clean followed by asynchronous build dependencies:
//build sub-tasks
gulp.task('bar', ['clean'], function(){...});
gulp.task('foo', ['clean'], function(){...});
gulp.task('baz', ['clean'], function(){...});
...
//main build task
gulp.task('build', ['foo', 'baz', 'bar', ...], function(){...})
Gulp is smart enough to run clean exactly once per build, no matter how many of build's dependencies depend on clean. As written above, clean is a synchronization barrier, then all of build's dependencies run in parallel, then build runs.