From 5f62c592a401517ed34ff42be00f4af5df80104b Mon Sep 17 00:00:00 2001 From: Sam Date: Mon, 12 Oct 2015 17:31:37 +1100 Subject: [PATCH] FEATURE: CSS_COMPILE_THREADS env setting for compiling CSS concurrently --- lib/tasks/assets.rake | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/lib/tasks/assets.rake b/lib/tasks/assets.rake index b220d322d4e..d52f42123c1 100644 --- a/lib/tasks/assets.rake +++ b/lib/tasks/assets.rake @@ -75,18 +75,27 @@ task 'assets:precompile:before' do end task 'assets:precompile:css' => 'environment' do - puts "Start compiling CSS: #{Time.zone.now}" - RailsMultisite::ConnectionManagement.each_connection do |db| + STDERR.puts "Start compiling CSS: #{Time.zone.now}" + + opts = {} + if (threads = ENV['CSS_COMPILE_THREADS'].to_i) > 0 + opts[:threads] = threads + end + + RailsMultisite::ConnectionManagement.each_connection(opts) do |db| # Heroku precompiles assets before db migration, so tables may not exist. # css will get precompiled during first request instead in that case. + if ActiveRecord::Base.connection.table_exists?(ColorScheme.table_name) - puts "Compiling css for #{db}" + STDERR.puts "Compiling css for #{db}" [:desktop, :mobile, :desktop_rtl, :mobile_rtl].each do |target| - puts DiscourseStylesheets.compile(target) + DiscourseStylesheets.compile(target) + STDERR.puts "target: #{target}" end end end - puts "Done compiling CSS: #{Time.zone.now}" + + STDERR.puts "Done compiling CSS: #{Time.zone.now}" end def assets_path