From fcbf9f1568c3365d786ef44e55ea8a11c10dec88 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 7 Apr 2014 09:38:00 -0700 Subject: [PATCH] avoid running Sass compilation twice --- .../lib/middleman-core/cli/build.rb | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/middleman-core/lib/middleman-core/cli/build.rb b/middleman-core/lib/middleman-core/cli/build.rb index d2f300ec..b644fa90 100644 --- a/middleman-core/lib/middleman-core/cli/build.rb +++ b/middleman-core/lib/middleman-core/cli/build.rb @@ -185,9 +185,7 @@ module Middleman::Cli @app.sitemap.resources.select do |resource| resource.ext == '.css' - end.each do |resource| - @rack.get(URI.escape(resource.destination_path)) - end + end.each(&method(:build_resource)) logger.debug '== Checking for Compass sprites' @@ -210,25 +208,29 @@ module Middleman::Cli end # Loop over all the paths and build them. - resources.each do |resource| - next if @config[:glob] && !File.fnmatch(@config[:glob], resource.destination_path) - - output_path = render_to_file(resource) - - if should_clean? && output_path.exist? - if RUBY_PLATFORM =~ /darwin/ - # handle UTF-8-MAC filename on MacOS - - @to_clean.delete(output_path.realpath.to_s.encode('UTF-8', 'UTF-8-MAC')) - else - @to_clean.delete(output_path.realpath) - end - end - end + resources.reject do |resource| + resource.ext == '.css' + end.each(&method(:build_resource)) ::Middleman::Profiling.report('build') end + def build_resource(resource) + return if @config[:glob] && !File.fnmatch(@config[:glob], resource.destination_path) + + output_path = render_to_file(resource) + + if should_clean? && output_path.exist? + if RUBY_PLATFORM =~ /darwin/ + # handle UTF-8-MAC filename on MacOS + + @to_clean.delete(output_path.realpath.to_s.encode('UTF-8', 'UTF-8-MAC')) + else + @to_clean.delete(output_path.realpath) + end + end + end + # Render a resource to a file. # # @param [Middleman::Sitemap::Resource] resource