Skip to content

Question: Gulp 4.0 Conventions For Tasks #771

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dman777 opened this issue Nov 15, 2014 · 10 comments
Closed

Question: Gulp 4.0 Conventions For Tasks #771

dman777 opened this issue Nov 15, 2014 · 10 comments

Comments

@dman777
Copy link

dman777 commented Nov 15, 2014

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')); where clean and all are also gulp tasks called within task default.

In 3.0, this would be done with

function clean() {}
function all() {}
gulp.task('default', function () {
    Promise.all([clean(), all()]);
})

Reference:
#458 (comment)
#755 (comment)

@yocontra yocontra changed the title Question: Gulp 4.0 Conventions For Tasks Question: Gulp 4.0 Conventions For Tasks Nov 15, 2014
@yocontra
Copy link
Member

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

@yocontra
Copy link
Member

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

@phated
Copy link
Member

phated commented Nov 16, 2014

Everything is just function composition in gulp4. There should be no more need to add extra wrappers, etc.

@jasonkarns
Copy link

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

@stringparser
Copy link

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'));

@jasonkarns
Copy link

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']))

@jasonkarns
Copy link

I didn't mean to hijack the thread. Should this be a separate discussion?

@phated
Copy link
Member

phated commented Nov 19, 2014

@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 😄

@phated phated added the gulp4 label Dec 12, 2014
@phated phated modified the milestone: gulp 4 Dec 12, 2014
@yocontra
Copy link
Member

Closing this since it already exists on the 4.0 branch

@geirsagberg
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants