1
0
Fork 0
mirror of https://github.com/middleman/middleman.git synced 2022-11-09 12:20:27 -05:00

Process resources for asset_hash extension in a specific order. This makes sure static assets (images, fonts) get their paths modified before assets that include them (css, js).

This commit is contained in:
Ben Hollis 2013-04-08 00:50:58 -07:00
parent 1617875934
commit 023ea9f34e

View file

@ -35,7 +35,18 @@ module Middleman
# Update the main sitemap resource list
# @return [void]
def manipulate_resource_list(resources)
resources.each do |resource|
# Process resources in order: binary images and fonts, then SVG, then JS/CSS.
# This is so by the time we get around to the text files (which may reference
# images and fonts) the static assets' hashes are already calculated.
resources.sort_by do |a|
if %w(.svg).include? a.ext
0
elsif %w(.js .css).include? a.ext
1
else
-1
end
end.each do |resource|
next unless @exts.include? resource.ext
next if @ignore.any? { |ignore| Middleman::Util.path_match(ignore, resource.destination_path) }