As part of Middleman Gulp Starter I’m dynmically ignoring files that are generated for production, through the external_pipeline
. I do this because I rev file assets.
I have a helper method that uses a rev-manifest.json
file with filenames before and after, which replaces filenames in the markup.
Example JSON file:
{
"images/projects/main@2x.png": "images/projects/main@2x-65c6dca131.png",
"images/sketchbook.png": "images/sketchbook-7186e78338.png",
"images/sketchbook@2x.png": "images/sketchbook@2x-dfb248c398.png",
"images/sublime.png": "images/sublime-4d33853f64.png",
"images/sublime@2x.png": "images/sublime@2x-576a3756f2.png",
"javascripts/app.js": "javascripts/app-77f18c61ff2f2d2dfecf.js",
"stylesheets/app.css": "stylesheets/app-854d14d5d7.css"
}
As part of this I have to ignore all of the original files from Middleman or you end up with both.
This is the function after the json file has been retrieved:
# Check to see if file revving is enabled
rev_manifest = REV_MANIFEST if defined?(REV_MANIFEST)
# If file revving is enabled we need to ignore the original files
# as they will still get copied by Middleman
if rev_manifest
rev_manifest.each do |key, value|
ignore key
end
# Ignore the actual manifest file itself
ignore 'rev-manifest.json'
end
Sometimes it works flawlessly and sometimes it doesn’t work at all and I end up with both assets
I’m wondering whether this is because this is happening in parallel somehow?
Any thoughts would be appreciated.