Gulp.js task, return on src?

后端 未结 3 1320
别跟我提以往
别跟我提以往 2020-11-28 02:10

I\'m new to gulp and have been looking through example set-ups. Some people have the following structure:

gulp.task(\"XXXX\", function() {
    gulp.src(\"...         


        
3条回答
  •  执笔经年
    2020-11-28 02:26

    I found this helpful, if you have multiple streams per task. You need to combine/merge the multiple streams and return them.

    var gulp = require('gulp');
    var merge = require('gulp-merge');
    
    gulp.task('test', function() {
        var bootstrap = gulp.src('bootstrap/js/*.js')
            .pipe(gulp.dest('public/bootstrap'));
    
        var jquery = gulp.src('jquery.cookie/jquery.cookie.js')
            .pipe(gulp.dest('public/jquery'));
    
        return merge(bootstrap, jquery);
    });
    

    The alternative, using Gulps task definition structure, would be:

    var gulp = require('gulp');
    
    gulp.task('bootstrap', function() {
        return gulp.src('bootstrap/js/*.js')
            .pipe(gulp.dest('public/bootstrap'));
    });
    
    gulp.task('jquery', function() {
        return gulp.src('jquery.cookie/jquery.cookie.js')
            .pipe(gulp.dest('public/jquery'));
    });
    
    gulp.task('test', ['bootstrap', 'jquery']);
    

提交回复
热议问题