小编sri*_*igi的帖子

如何管理到Gulp的另一项任务?

我试着干我的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/'))
});
Run Code Online (Sandbox Code Playgroud)

我得到了index一个单独的任务,因为我需要注意src/index.htmllivereload.但我也在关注我的.coffee消息来源,当他们改变时,我也需要更新src/index.html.

怎么管道index进去scripts

gulp gulp-watch

19
推荐指数
1
解决办法
2万
查看次数

标签 统计

gulp ×1

gulp-watch ×1