如何在管道中间添加 src 文件 [英] How to add src files in the middle of a pipe

查看:19
本文介绍了如何在管道中间添加 src 文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用'coffee'处理一些文件,添加一些js文件,concat和minify.

I want to process some files with 'coffee', add some js files, concat and minify.

这不起作用,咖啡在常规 js 文件上失败:

This does not work, coffee fails on the regular js files:

gulp.task 'build-js', ->
  gulp.src([
      "bower_components/mbdev-core/dist/js/db.js"
      "bower_components/mbdev-core/dist/js/utils.js"
      "src/js/config/app.coffee"
      "src/js/config/app-db.coffee"              
      "src/js/accounts/accounts.coffee"
      "src/js/budget_items/budget_items.coffee"
      "src/js/line_items/line_items.coffee"
      "src/js/misc/misc.coffee"
      "src/js/reports/report_generators.coffee"
      "src/js/reports/reports.coffee"
   ])
  .pipe(coffee()).on('error', gutil.log)
  .pipe(concat('app.js'))
  .pipe(gulp.dest('public/js'))

有没有办法在咖啡部分之后添加文件?

Is there a way to add files after the coffee part?

推荐答案

不需要在原来的src中添加文件,而是使用coffee only "if"...

You don't need to add files to the original src, but rather to use coffee only "if"...

所以,使用 gulp-if

gulp.task('task', function() {
  gulp.src('./stuff/*')
    .pipe(gulpif(/[.]coffee$/, coffee()))
    .pipe(gulp.dest('./dist/'));
});

请参阅此处了解有关 gulp-if 的更多信息.

See here more about gulp-if.

这篇关于如何在管道中间添加 src 文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆