Unpredictable file order in gulp

bodyflex

I have the following task:

var inject = require('gulp-inject');
...
gulp.task('index-build', function () {
    return gulp.src(config.index)
        .pipe(
            inject(gulp.src(config.build + '/vendor/**/*.js', { read: false }))
        )
        .pipe(gulp.dest(config.build));
});

Mostly this does what it's supposed to: concatenate files in alphabetic order within the paths, resulting in something like:

    ...
    <script src="/vendor/angular/angular.js"></script>
    <script src="/vendor/angular-resource/angular-resource.js"></script>
    ...

but sometimes, irregularly, it does this:

    ...
    <script src="/vendor/angular-resource/angular-resource.js"></script>
    <script src="/vendor/angular/angular.js"></script>
    ...

Which breaks the app since angular-resource.js depends on angular.js.

Why does gulp do this unpredictably and how do I assure that the order is the same each time?

harishr

use gulp-sort to get the file in alphabetical sequence.

The plugins do output the files in the sequence in which they receive it, hence the sequence of files is even out of their control.

and its actually good that they dont sort the files, the plugin should only do what it is supposed to do and add nothing extra.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related