Output is not consistent even when files don't change
Closed this issue · 3 comments
Thanks for providing this tool! I'm using it just to write out a JSON file containing the hashes of all of my static assets, and it's working great for that task.
The problem is that the tool ends up writing out results in a different order each time it runs -- even if the source input files have not changed themselves. As I have the resulting JSON file checked in to version control, the continual changing of the file is becoming a bit of an annoyance. I'd much prefer if it would output the results in a consistent order each time.
That sounds reasonable. But in my use case, I just don't track the hash.json
in git. When deloying, the grunt task happens on server, too. Maybe I'm doing it the wrong way.
I don't think there's a "wrong" way, but we both have different needs/approaches. Our deploys are essentially just git pull
-- there's no processing that happens on the server, so what's checked in are ultimately our production bits (and assethash.json).
I don't dynamically rename the files based on the hash, I actually use [IIS] rewrite rules to simply rewrite the URLs without the hash component, and ultimately serve the original file off the disk. It gives me the best of both worlds -- versioned URLs with far-future expires headers, but minimal overhead in terms of temp/renamed files on disk and in version control. (For more details on how I handle this, see http://stackoverflow.com/questions/17845193/versioning-static-resources-in-handlebarsjs-templates).
In any case, having a more consistent ordering to the JSON blob could be a good thing in multiple scenarios, as it makes it easier to diff versions as well, even if they're not in source control.
Appreciate your openness to taking this update!
The rewrite approach sounds great.
A version of 0.1.4 has been published to npm. Thanks for your pull request.