Closed dman777 closed 9 years ago
You can also do this
function clean() {}
function all() {}
gulp.task('default', gulp.series(clean, all))
series and parallel take strings or functions, strings just look up the function from the task object
Docs for the underlying lib: https://github.com/phated/bach
For the 4.0 release I really want to consolidate the spiderweb of docs into one place
Everything is just function composition in gulp4. There should be no more need to add extra wrappers, etc.
What's the simplest form for task aliasing? (for the default task?)
gulp.task('default', gulp.series('build'))
seems a bit verbose for a simple alias
But is way powerful.
gulp.task('css:pipeline', gulp.series('stylus', 'autoprefixer'));
gulp.task('js:pipeline', gulp.series('jsx', 'lint', 'minify'));
gulp.task('default', gulp.parallel('js:pipeline','css:pipeline'));
Yeah! I certainly don't want to downplay the many-to-one feature. And I don't think an increased api surface area is warranted (e.g. gulp.alias
or something). But keeping gulp.task('default', 'other')
doesn't seem unreasonable. (Or gulp.task('default', ['other'])
)
I didn't mean to hijack the thread. Should this be a separate discussion?
@jasonkarns I will try to answer here, but if it isn't satisfactory, please open a new issue.
The simplest way to alias a task is as such:
function build(){
// do your build stuff
}
gulp.task(build);
gulp.task('default', build);
Remember, everything is a function :smile:
Closing this since it already exists on the 4.0 branch
gulp.task('default', 'build')
should be synonymous with gulp.task('default', gulp.series('build'))
IMO. When I tried wrapping the build
task in a function as suggested, gulp won't log anything from the nested tasks:
function build(){
return gulp.parallel(buildScripts, buildLess);
}
gulp.task(build);
gulp.task('default', build);
With 4.0, is the intended code flow(gulp convention) no longer calling outside normal javascript functions(non task wrapped) inside a wrapped task?
The reason why I ask is because I see:
gulp.task('default', gulp.parallel('clean', 'all'));
whereclean
andall
are also gulp tasks called within taskdefault
.In 3.0, this would be done with
Reference: https://github.com/gulpjs/gulp/issues/458#issuecomment-62057370 https://github.com/gulpjs/gulp/issues/755#issuecomment-61884019