diff --git a/middleman-core/features/asset_hash.feature b/middleman-core/features/asset_hash.feature index 9f8aa742..a4f3ec01 100644 --- a/middleman-core/features/asset_hash.feature +++ b/middleman-core/features/asset_hash.feature @@ -47,6 +47,15 @@ Feature: Assets get a file hash appended to their and references to them are upd And the file "subdir/api.json" should contain 'images/100px-5fd6fb90.jpg' And the file "subdir/api.json" should contain 'images/100px-1242c368.png' + Scenario: Hashed fonts assets work with woff and woff2 extension + Given a successfully built app at "asset-hash-app" + When I cd to "build" + Then the following files should exist: + | fonts/fontawesome-webfont-56ce13e7.woff | + | fonts/fontawesome-webfont-10752316.woff2 | + And the file "stylesheets/uses_fonts-88aa3e2b.css" should contain "src: url('../fonts/fontawesome-webfont-10752316.woff2')" + And the file "stylesheets/uses_fonts-88aa3e2b.css" should contain "url('../fonts/fontawesome-webfont-56ce13e7.woff')" + Scenario: Hashed assets work in preview server Given the Server is running at "asset-hash-app" When I go to "/" diff --git a/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff b/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff new file mode 100644 index 00000000..8b280b98 Binary files /dev/null and b/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff differ diff --git a/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 b/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 new file mode 100644 index 00000000..3311d585 Binary files /dev/null and b/middleman-core/fixtures/asset-hash-app/source/fonts/fontawesome-webfont.woff2 differ diff --git a/middleman-core/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css b/middleman-core/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css new file mode 100644 index 00000000..629429d0 --- /dev/null +++ b/middleman-core/fixtures/asset-hash-app/source/stylesheets/uses_fonts.css @@ -0,0 +1,4 @@ +@font-face { + font-family: 'FontAwesome'; + src: url('../fonts/fontawesome-webfont.woff2') format('woff2'), url('../fonts/fontawesome-webfont.woff') format('woff'); +} diff --git a/middleman-core/lib/middleman-more/extensions/asset_hash.rb b/middleman-core/lib/middleman-more/extensions/asset_hash.rb index 7f273820..e44218ee 100644 --- a/middleman-core/lib/middleman-more/extensions/asset_hash.rb +++ b/middleman-core/lib/middleman-more/extensions/asset_hash.rb @@ -63,7 +63,7 @@ class Middleman::Extensions::AssetHash < ::Middleman::Extension @rack_app = app @exts = options[:exts] @ignore = options[:ignore] - @exts_regex_text = @exts.map { |e| Regexp.escape(e) }.join('|') + @exts_regex_text = @exts.map { |e| Regexp.escape(e) }.sort.reverse.join('|') @middleman_app = options[:middleman_app] end