klei / gulp-angular-filesort

Automatically sort AngularJS app files depending on module definitions and usage
MIT License
132 stars 46 forks source link

All files are in reverse order #44

Open cluka opened 8 years ago

cluka commented 8 years ago

if i run this task:

gulp.task('test',
    function () {
        return gulp.src(['./app/**/*.js']).pipe(angularFilesort()).pipe(filelog());

    });

i get js files in reverse order. Ie. my app.js is at the last position instead of first. etc.

seanmarthur commented 8 years ago

I have the same issue... this is driving me nuts!

    var injectOpts = {addRootSlash: false};
    var injectStyles = gulp.src(['./src/**/*.css'], {read: false});
    var injectScripts = gulp.src(['./src/app/**/*.js']).pipe(angularFilesort());

    return target.pipe(inject(injectStyles, injectOpts))
        .pipe(inject(injectScripts, injectOpts))
        .pipe(wiredep())
        .pipe(useref({
            searchPath: ['bower_components', './']
        }))
        .pipe(gulpif('*.js', uglify()))
        .pipe(gulpif('*.css', minifyCss()))
        .pipe(sourcemaps.init())
        .pipe(sourcemaps.write('maps'))
        .pipe(gulp.dest('./dist'));

Files are ordered in reverse with app.js as the last file in the bundle. If I take out useref, the individual (unbundled) file script tags are also in reverse order.

seanmarthur commented 8 years ago

This is ridiculous, but my fix for this issue is to run angularFileSort twice.

.pipe($.angularFilesort()).pipe($.angularFilesort());

mrdulin commented 8 years ago

Seems I have this issue too.Here is my code gist: image

image

image

Throw angular is not defined Error: image

And, like @seanmarthur said, run angularFileSort twice will solve the problem.

correct order: image

clear image

joakimbeng commented 8 years ago

You shouldn't pass external dependencies (i.e. 3rd party libs) through this plugin! See this comment on #8. See #45 as well, perhaps you don't have to use this plugin at all? Have you tried commenting it out and do you get errors then?