title: Concat scripts in order with Gulp
body: <p>Say, for example, you are building a project on Backbone or whatever and you need to load scripts in a certain order, e.g. <code>underscore.js</code> needs to be loaded before <code>backbone.js</code>.</p>
  
  <p>How do I get it to concat the scripts so that they’re in order? </p>
  
  <pre><code>// JS concat, strip debugging and minify
  gulp.task('scripts', function() {
      gulp.src(['./source/js/*.js', './source/js/**/*.js'])
      .pipe(concat('script.js'))
      .pipe(stripDebug())
      .pipe(uglify())
      .pipe(gulp.dest('./build/js/'));
  });
  </code></pre>
  
  <p>I have the right order of scripts in my <code>source/index.html</code>, but since files are organized by alphabetic order, gulp will concat <code>underscore.js</code> after <code>backbone.js</code>, and the order of the scripts in my <code>source/index.html</code> does not matter, it looks at the files in the directory.</p>
  
  <p>So does anyone have an idea on this?</p>
  
  <p>Best idea I have is to rename the vendor scripts with <code>1</code>, <code>2</code>, <code>3</code> to give them the proper order, but I am not sure if I like this.</p>
  
  <p>As I learned more I found Browserify is a great solution, it can be a pain at first but it’s great.</p>