gulp-community / gulp-concat

Streaming concat middleware for gulp
MIT License
792 stars 127 forks source link

How to ensure a file is concatenated last? #113

Closed qodesmith closed 8 years ago

qodesmith commented 8 years ago
gulp.task('scripts', function() {
  return gulp.src(['!dev/js/vendor-list.js', 'dev/js/**/*.js'])
    .pipe(concat('all.min.js'))
    .pipe(gulp.dest('public'));
});

If I run the above, everything get's concatenated as it should, ignoring vendor-list.js. Lumped in there somewhere is app.js. The problem is, I need app.js concatenated last. I tried the following to no avail (just me guessing):

gulp.task('scripts', function() {
  return gulp.src(['!dev/js/vendor-list.js', 'dev/js/**/*.js', 'dev/js/app.js'])
    .pipe(concat('all.min.js'))
    .pipe(gulp.dest('public'));
});

While the concatenation still works, unfortunately app.js isn't tacked on the the end of the resulting file. Is there a way to do this? I thought about doing two streams in the scripts task and then merging them, but I was hoping for a simpler solution. Thank you!

qodesmith commented 8 years ago

Pasting the answer from the SO question I posted:

[
  '!dev/js/vendor-list.js', // can probably be included in the statement below.
  '/dev/js/!(app)*.js', // all files that end in .js EXCEPT app*.js
  '/dev/js/app.js', // this should be concatenated last
]