我尝试干燥我的 gulpfile。那里有一些我不喜欢的代码重复。怎样才能做得更好?
gulp.task('scripts', function() {
return gulp.src('src/scripts/**/*.coffee')
.pipe(coffeelint())
.pipe(coffeelint.reporter())
.pipe(coffee())
.pipe(gulp.dest('dist/scripts/'))
.pipe(gulp.src('src/index.html')) // this
.pipe(includeSource()) // needs
.pipe(gulp.dest('dist/')) // DRY
});
gulp.task('index', function() {
return gulp.src('src/index.html')
.pipe(includeSource())
.pipe(gulp.dest('dist/'))
});
我得到了index
一个单独的任务,因为我需要观看src/index.html
livereload。但我也在关注我的.coffee
资源,当它们发生变化时,我也需要更新src/index.html
。
我如何通过管道index
输入scripts
?