gulp-note-all-in-here

This post is all about issues come up when I use gulpjs.

Multiple gulp process flow working with runing tasks in sequence demand.

  • 1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    gulp.task('someTask', function(){
    if (gulpConfig.multi-dist){
    const stream = merge();
    _.forEach(gulpConfig.branches, function (name) {
    stream.add(
    gulp.src('biz/*.html')
    .pipe(gulp-plumber(errorHandler))
    .pipe(gulp-newer('./dest/' + name))
    .pipe(gulp.dest('./dest/' + name))
    );
    })
    return stream;
    }
    });
  • By doing this, now can run this multiple working flow with other tasks in sequence.

alter gulp dest path through gulp-rename

1
srcPath = path.join(component, '*', 'lib/**/*')
1
2
3
4
5
6
7
8
9
10
11
12
function getJsStream(srcPath, distPath){
return gulp.src(srcPath)
.pipe(gulp-plumber(errorHandler))
// .pipe(gulp-logger({showChange: true}))
.pipe(rename(function(file) {
var pathArr = file.dirname.split(path.sep);
pathArr.splice(1,1); //切掉lib
file.dirname = pathArr.join(path.sep);
}))
.pipe(gulp-newer(distPath))
.pipe(gulp.dest(distPath));
}