How to perform multiple gulp commands in one task

后端 未结 1 1866
情书的邮戳
情书的邮戳 2021-02-01 22:58

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) {
    gul         


        
相关标签:
1条回答
  • 2021-02-01 23:06

    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'));
    });
    
    0 讨论(0)
提交回复
热议问题