-1

Why Gulp is doing wrong (or its ok, but i need something else) order in concating files?

Here is image for example (on the left, my scripts order and on the right concated file) :

enter image description here

Notificator.js should be on first place...

Folder notificator is in /components/notificator. Here is my gulpfile.js:

gulp.src('./htdocs/js/components/**/*.js')
        .pipe(concat('components.js'))
        .pipe(gulp.dest('./htdocs/dist/js/')),
Skodsgn
  • 940
  • 1
  • 10
  • 33
  • How is gulp supposed to know the order you want? Do you just expect the files to be concatenated in alphabetical order or something more complicated? – Sven Schoenung Jan 02 '17 at 18:02
  • Same order as in my files order :) – Skodsgn Jan 02 '17 at 18:16
  • How exactly am I or is anyone else supposed to know how your files are ordered? Asciibetical? Ignore the extension? Case-sensitive? Unless you specify exactly how the files should be ordered this question is not useful. – Sven Schoenung Jan 02 '17 at 18:24
  • Exacly as is in image i posted. Alphabetically. – Skodsgn Jan 02 '17 at 18:31
  • Possible duplicate of [gulp concat scripts in order?](http://stackoverflow.com/questions/21961142/gulp-concat-scripts-in-order) – Dejan.S Jan 02 '17 at 19:22

1 Answers1

2

You can pass in a array as source like this,

gulp.src(['PATHTOFILE', 'PATHTOFILE'])
        .pipe(concat('components.js'))
        .pipe(gulp.dest('./htdocs/dist/js/'))

or you can use something called gulp-useref, that basically it runs through your decalare in the html and concat them in that order.

Dejan.S
  • 18,571
  • 22
  • 69
  • 112
  • For me that that is the prefered way to do it, all in one place. There is an alternative though, a gulp package, gulp-useref, https://www.npmjs.com/package/gulp-useref @Sko – Dejan.S Jan 02 '17 at 19:18