Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
373 views
in Technique[技术] by (71.8m points)

coffeescript - How to add src files in the middle of a pipe

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

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

So, use gulp-if

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

See here more about gulp-if.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...