Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Control order of source files

Tags:

gulp

bower

I'm using Gulp and the main-bower-files to bundle my bower dependencies.

I need to ensure that jQuery is included before AngularJS, but since the Angular bower package does not actually depend on jQuery it is included after.

Is there a way to push jQuery to the top of source list or override Angular's dependency so it does require jQuery?

I tried using the gulp-order plugin to do this but it messes up the original order of the remaining files:

gulp.task('bower', function () {

  var sources = gulp.src(mainBowerFiles(['**/*.js', '!**/*.min.js'])); // don't include min files

  return sources
    // force jquery to be first
    .pipe(plugins.order([
      'jquery.js',
      '*'
    ]))
    .pipe(plugins.sourcemaps.init())
      .pipe(plugins.concat('libs.min.js'))
      .pipe(plugins.uglify())
    .pipe(plugins.sourcemaps.write('./'))
    .pipe(gulp.dest(config.output))
    .pipe(plugins.notify({ message: 'Bower task complete' }));
});
like image 748
Ben Foster Avatar asked Mar 12 '15 12:03

Ben Foster


People also ask

How do I change the order of files on a GitHub repository?

You can control the order by adding one or more spaces before the name. The space will not be shown after editing, but the order will change. E.g: lets say we have 3 files with the automatic order: AFile.

Can you change the order of files in a folder?

To change the order of a file or folder, click the dots on to the left of the folder or file's name that you're interested in. Dragging while clicking will move the file or folder up and down. A gray outline will show you where the file will appear if you drop it at that point.


1 Answers

You can override angulars dependencies in your project bower.json:

https://github.com/ck86/main-bower-files#overrides-options

{
    ...

    "overrides": {
        "angular": {
            "dependencies": {
                "jquery": "~1.8"
            }
        }
    }
}
like image 196
Thomas B Homburg Avatar answered Nov 05 '22 13:11

Thomas B Homburg