christophercliff / metalsmith-fingerprint

A fingerprint plugin for Metalsmith
MIT License
28 stars 7 forks source link

Why is the original file kept? #5

Closed callum closed 9 years ago

callum commented 9 years ago

I might be overlooking the obvious, but why is the original file kept in the pipeline? Both files are written to the build directory.

mikehayesuk commented 9 years ago

:+1:

I would also like to discard the original file, having unnecessary duplicates in my build directory and production feels wrong!

callum commented 9 years ago

@BlueHayes made a PR here https://github.com/christophercliff/metalsmith-fingerprint/pull/6

christophercliff commented 9 years ago

I'll leave this open for now, but recommend you make use of https://github.com/segmentio/metalsmith-ignore to clean up your build directory.

mikehayesuk commented 9 years ago

Thanks for the recommendation, do you have any suggested ways to use metalsmith-ignore to pick up on non-fingerprinted files? It seems like it may be difficult (and not very reliable) unless I'm missing a trick.

christophercliff commented 9 years ago

I use it like this: https://github.com/christophercliff/christophercliff.github.io/blob/5af8ce62e6cf1e823a4cbc46aade9cb52e1beb1a/build.js#L54-L59

mikehayesuk commented 9 years ago

Ah I see. I'm doing the same for my less directory now (thanks for the plugin tip). However I'm applying the fingerprint plugin against "images/*/", so in the build directory we end up with e.g. "images/logo.jpg" and "images/logo-[hash].jpg" for a whole bunch of images. So in this kind of setup it could make sense for the fingerprint plugin to dispose of duplicated images itself.

christophercliff commented 9 years ago

Try the https://github.com/isaacs/minimatch docs.

callum commented 9 years ago

I'm already using metalsmith-ignore in my project @christophercliff, but I'm still interested in the rationale behind keeping files. I don't see it as desired behaviour.

callum commented 9 years ago

I'm matching on all images with this https://github.com/callum/sparks-inc.org/blob/master/build.js#L32. The reason the ignore plugin doesn't work is because it doesn't have knowledge of the files that have been fingerprinted. There's no reliable way to match against the files that have been passed through, unless you recalculated the md5 hash and used that. This is the same issue @BlueHayes is describing.

christophercliff commented 9 years ago

Would something like this solve your problem? http://www.globtester.com/#p=eJxLLi7WV9TQ0tXS1EsuLgYAHPgD4w%3D%3D&r=eJyzScksU0jOSSwutlXKTSxJzlCySy4u1s%2FMS0mt0AOybPSBCuxskFQhKdBNM0oytLBIMzNLSzY3STROSzI2MTO3TLMwNDc0NTVNMkSYAAA0hyF8&

screen shot 2015-05-26 at 2 45 31 pm

mikehayesuk commented 9 years ago

This would still leave any images in the build dir which have a hyphen in the filename. It's helpful but doesn't cover all cases.

Example: Globtester

http://www.globtester.com/#p=eJzLzE1MTy3WV9TQ0tXS1NMCACYPA%2FE%3D&r=eJy1j0EOgjAQRa9C2AsWaEu19C5TaAFToGGIUU%2BvEBdiiCYmzvrlvT%2Byas9B6QCxCDuYyiZUbQe1wdgN9RD5vpbxA1HyhVshO5tokueWMVvyDFKr04xxYXPCCaVUk23HutUYqMwYnfxmTaKHPsDp6kwR2qGfdtjezCEgIkr283GWiFRQfzm%2BGb%2BPW5KzX0k9qg%2B%2FPoXYgXN%2FGLp4f5t7B1lIkDk%3D&

callum commented 9 years ago

Yeah maybe but that's what I mean by reliably. What if a file is named 'something-somethingelse.css'

^^ @BlueHayes that

slavafomin commented 6 years ago

Why is this issue closed?