1

I am using gulp with bower and a number of other scripts with the following directory structure:

.
|- bower_components
|---- various_packages
|- js
|---- functions.js (my custom javascript)
|---- test_example_vendor_item.js

My gulp is using main-bower-files to grab the bowser files, and then concatenates my other js files.

The main problem is that within the js folder itself, I need functions.js to be concatenated after test_example_vendor_item.js.

Apart from simply renaming functions.js to zzz_functions.js, or all the other files to zzz_vendor.example.js, is there a way to ensure that functions.js is concatenated last?

I'm trying to use gulp-order to no avail, evidently as the initial wildcard will accept all in its original order:

gulp.task('js', function() {
  var jsFiles = ['js/*'];
  gulp.src(plugins.mainBowerFiles().concat(jsFiles))
      .pipe(plugins.filter('*.js'))
      .pipe(plugins.order([
        '*',
        'functions.js'
      ]))
      .pipe(plugins.concat('main.js'))
      .pipe(plugins.uglify())
      .pipe(gulp.dest(dest + 'js'))
});
waffl
  • 5,179
  • 10
  • 73
  • 123
  • possible duplicate of [gulp concat scripts in order?](http://stackoverflow.com/questions/21961142/gulp-concat-scripts-in-order) – Gnarlywhale Jul 30 '15 at 18:00

2 Answers2

1

Sure . . .

 gulp.task('js', function() {
   var jsFiles = ['js/*'];
   gulp.src(plugins.mainBowerFiles().concat(jsFiles))
    .pipe(plugins.filter('*.js'))
    .pipe(plugins.order([
      '!(functions.js)*',
      'functions.js'
    ]))
    .pipe(plugins.concat('main.js'))
    .pipe(plugins.uglify())
    .pipe(gulp.dest(dest + 'js'))
});

The idea is to select all js files except for functions.js, and then to select functions.js.

chuck w
  • 1,741
  • 2
  • 15
  • 34
0

*try this:

.pipe(plugins.order([
  '!(functions.js)*',
  'functions.js'
]))
chuck w
  • 1,741
  • 2
  • 15
  • 34