From d969958b189d729a9eda421d509a1d4c8fd9cb0f Mon Sep 17 00:00:00 2001 From: Sam Date: Tue, 4 Mar 2014 17:16:53 +1100 Subject: [PATCH] PERF: workaround aweful sass compiling perf with HUGE css files --- lib/tasks/assets.rake | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index 6144e5307a1..4b2662dfc60 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -34,12 +34,21 @@ task 'assets:precompile:before' do class SassCompressor def evaluate(context, locals, &block) ::Sprockets.cache_compiled("sass", data) do - ::Sass::Engine.new(data, { - :syntax => :scss, - :cache => false, - :read_cache => false, - :style => :compressed - }).render + # HACK, SASS compiler will degrade to aweful perf with huge files + # Bypass if larger than 200kb, ensure assets are minified prior + if context.pathname && + context.pathname.to_s =~ /.css$/ && + data.length > 200.kilobytes + puts "Skipped minifying #{context.pathname} cause it is larger than 200KB, minify in source control or avoid large CSS files" + data + else + ::Sass::Engine.new(data, { + :syntax => :scss, + :cache => false, + :read_cache => false, + :style => :compressed + }).render + end end end end @@ -48,7 +57,7 @@ task 'assets:precompile:before' do def evaluate(context, locals, &block) ::Sprockets.cache_compiled("uglifier", data) do - Uglifier.new(:comments => :none).compile(data) + Uglifier.new(:comments => :none).compile(data) end end