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

All the pull requests #77

Closed bobthecow closed 9 years ago

bobthecow commented 9 years ago

This includes @jaypea's #69, with a couple of changes:

This also includes @goldibex's #75, but merged into changes from #69 (plus a few minor code style changes).

Thoughts? /cc @sindresorhus @jaypea @goldibex

sindresorhus commented 9 years ago

Very nice work @bobthecow @jaypea @goldibex!

Mentioning some people that needs this so they can review and make sure it solves their need: @ijy @thebuilder @davidtheclark @netm @jk- @xwk @tomhalley89 @pkuliga @didoo @c0 @codekirei @n8agrin @micahlmartin

sindresorhus commented 9 years ago

You can try it out with:

npm install 'bobthecow/gulp-rev#all-the-pull-requests'
bobthecow commented 9 years ago

All feedback addressed.

bobthecow commented 9 years ago

With this latest change, rev.manifest doesn't concern itself with paths or bases or anything. Those options are simply passed through to vinyl to create a manifest file. I feel like this is the ideal way to handle it, and is super flexible, but some people are going to get confused about why their manifest file gets written where it does, or why it doesn't merge...

This one won't merge, because it will be looking for a file called rev-manifest.json in cwd:

// ...
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest({merge: true}))
.pipe(gulp.dest('dist'));

This one would merge (if dist/rev-manifest.json existed), but it will write the resulting manifest file to dist/dist/rev-manifest.json:

// ...
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest('dist/rev-manifest.json', {merge: true}))
.pipe(gulp.dest('dist'));

This one would work perfectly, but the two different gulp.dest arguments are a bit confusing:

// ...
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest('dist/rev-manifest.json', {merge: true}))
.pipe(gulp.dest(''));

This is the right one, but nobody actually knows how path, base and cwd play together in vinyl, so most people prolly won't do this on the first try:

// ...
.pipe(rev())
.pipe(gulp.dest('dist'))
.pipe(rev.manifest({base: process.cwd() + '/dist', merge: true}))
.pipe(gulp.dest('dist'));
bobthecow commented 9 years ago

@sindresorhus One outstanding question: Should we make the manifest backwards compatible by snagging the manifest file if it comes by in the stream? I'm happy with a BC break here, but it's your call.

sindresorhus commented 9 years ago

Awesome work @bobthecow :)

Should we make the manifest backwards compatible by snagging the manifest file if it comes by in the stream?

No

Sorry about the delay all. I'd like to merge this a quick as possible. Anything I can do to make it happen.

bobthecow commented 9 years ago

No

kk. i'll make that base change. do we want to hold off on a merge until people confirm? it doesn't look like anyone's paying attention to the issue :)

sindresorhus commented 9 years ago

Nah, too bad for them if it doesn't solve their use-case. They've had lots of opportunities to give feedback. We can iterate later on if needed.

bobthecow commented 9 years ago

base fixed in 7962cf6

sindresorhus commented 9 years ago

Alright. Late here, so gonna look it over one last time tomorrow morning and merge then.

ijy commented 9 years ago

I'll be able to give this a test tomorrow if it helps. Sorry for the delay, it's been pretty busy of late. This looks like it should solve the problem once and for all. The time and consideration put into it is certainly not unnoticed or unappreciated. Thanks guys. Will kick the tyres tomorrow.

bobthecow commented 9 years ago

@sindresorhus one more, from earlier in the thread:

The readme could use a bit of hierarchy help. Specifically, Integration, Sourcemaps and Works with seem to be at the wrong heading level.

bobthecow commented 9 years ago

@ijy Thanks! I hear you, I've been super busy myself :)

sindresorhus commented 9 years ago

@ijy Were you able to try it out?

montogeek commented 9 years ago

Merge please :)

sindresorhus commented 9 years ago

Landed! Thanks all :)

od3vvoq

bobthecow commented 9 years ago

Thanks @sindresorhus!

austinpray commented 9 years ago

Sweeeeet.

SimenB commented 9 years ago

I wasn't able to make this work using options.base (everytime I used it, the json-file was placed in root). The I looked at the tests, and it used options.path. If I used path as well I got it to work.

Am I doing something wrong (probably), or is the documentation wrong?

EDIT: I just noticed https://github.com/sindresorhus/gulp-rev/pull/77#issuecomment-68076646. Is that still the case?

bobthecow commented 9 years ago

Yes, that's still the case. See the "This is the right one, but nobody actually knows how path, base and cwd play together in vinyl, so most people prolly won't do this on the first try" :)

bobthecow commented 9 years ago

@sindresorhus I think that might be the happiest kitty ever made.