sindresorhus / gulp-rev

Static asset revisioning by appending content hash to filenames: `unicorn.css` → `unicorn-d41d8cd98f.css`
MIT License
1.54k stars 218 forks source link

Option to disable manifest sorting #207

Closed inbeacon closed 7 years ago

inbeacon commented 7 years ago

Because js files need to be included into a specific order (like: jQuery first) the default sorting of the output is not very useful. (ie. makes this module useless or very cumbersome) Can an option to disable sort be included?

sindresorhus commented 7 years ago

This module just creates a sorted manifest, that has no impact on the actual sorting in the stream. If you want to preserve that, see https://www.google.co.th/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=gulp+sort

inbeacon commented 7 years ago

It IS about sorting of the manifest. I am using gulp-order to get the order right, but rev.manifest then undoes this.

The manifest is used to generate a script header, using the order of the manifest. If the manifest gets sorted, we need to figure out the right sorting order using other methods, which is cumbersome.

I'm still using 2.0.1 as this version does not include the sorting, but this option would really be appreciated (and I saw others asking for this too, in another (closed) issue)

    var stream_hashed = gulp.src(destpath(coll) + '/copy/**/*.js', {nodir: true})//use all coppied files
        .pipe(rev())// add hashes
        // .pipe(filelog())
        .pipe(order(priority))//sort on priority to prevent javascript dependencies failing
        .pipe(gulp.dest(destpath(coll) + '/hashed'))
        .pipe(rev.manifest({merge: true})) // warning:  rev version >3.0.1 SORTS the files before making the manifest, this undo's the pipe(order())
        .pipe(rename("rev-manifest-js.json"))//rename manifest
        .pipe(gulp.dest(destpath(coll) + '/hashed'))//copy manifest to hashed location