I'm having a hard time to understand on how to process multiple gulp sources in a single task. In a task like this:
gulp.task('task1', function (cb) {
gulp.src('src/js/**/*').pipe(gulp.dest('dist'));
gulp.src('src/css/**/*').pipe(gulp.dest('dist'));
...
});
I would like to process all the different source files and then mark the task as finished, so the others tasks can depend on it's completion.
I'm aware of the possibility, to using individual tasks for each individual source but this would make everything more complicated and bloat the orchestrator with a huge number of tasks that are actually not needed individually.
You can pass an array of globs to gulp.src
if you are doing the same things to all files. For example,
gulp.task('task1', function () {
return gulp.src(['src/js/**/*', 'src/css/**/*']).pipe(gulp.dest('dist'));
});
Be sure to return the stream so the orchestrator knows when that task is complete.
If you are doing different things to the different sets of files, you can merge the streams like this in one task:
var es = require('event-stream');
gulp.task('fancy-task', function () {
return es.merge(
gulp.src('*.js').pipe(some-js-plugin()),
gulp.src('*.css').pipe(some-style-plugin))
.pipe(gulp.dest('dist'));
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With