From 185ab4c35cac281ca1ab5fd4cbed92dc02a1e35d Mon Sep 17 00:00:00 2001 From: Nate Hardison Date: Tue, 21 May 2013 10:43:58 -0700 Subject: [PATCH] Make Mako preprocessing a Rake task Per feedback from @cpennington. This way we'll only preprocess once, even if the Sass compilation is invoked multiple times. --- rakefiles/assets.rake | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/rakefiles/assets.rake b/rakefiles/assets.rake index ef77d4fea7..b7edaa1b02 100644 --- a/rakefiles/assets.rake +++ b/rakefiles/assets.rake @@ -25,13 +25,6 @@ def preprocess_with_mako(filename) end end -# Preprocess all static assets that have the .mako extension by -# running them through the Mako templating engine. Right now we -# just hardcode the asset filenames. -def preprocess_assets - preprocess_with_mako("lms/static/sass/application.scss.mako") -end - def xmodule_cmd(watch=false, debug=false) xmodule_cmd = 'xmodule_assets common/static/xmodule' if watch @@ -65,9 +58,6 @@ def coffee_cmd(watch=false, debug=false) end def sass_cmd(watch=false, debug=false) - # Make sure to preprocess templatized Sass first - preprocess_assets() - sass_load_paths = ["./common/static/sass"] sass_watch_paths = ["*/static"] if USE_CUSTOM_THEME @@ -89,6 +79,13 @@ namespace :assets do desc "Compile all assets in debug mode" multitask :debug + desc "Preprocess all static assets that have the .mako extension" + task :preprocess do + # Run assets through the Mako templating engine. Right now we + # just hardcode the asset filenames. + preprocess_with_mako("lms/static/sass/application.scss.mako") + end + desc "Watch all assets for changes and automatically recompile" task :watch => 'assets:_watch' do puts "Press ENTER to terminate".red @@ -97,9 +94,9 @@ namespace :assets do {:xmodule => :install_python_prereqs, :coffee => :install_node_prereqs, - :sass => :install_ruby_prereqs}.each_pair do |asset_type, prereq_task| + :sass => [:install_ruby_prereqs, :preprocess]}.each_pair do |asset_type, prereq_tasks| desc "Compile all #{asset_type} assets" - task asset_type => prereq_task do + task asset_type => prereq_tasks do cmd = send(asset_type.to_s + "_cmd", watch=false, debug=false) if cmd.kind_of?(Array) cmd.each {|c| sh(c)} @@ -114,7 +111,7 @@ namespace :assets do namespace asset_type do desc "Compile all #{asset_type} assets in debug mode" - task :debug => prereq_task do + task :debug => prereq_tasks do cmd = send(asset_type.to_s + "_cmd", watch=false, debug=true) sh(cmd) end @@ -125,7 +122,7 @@ namespace :assets do $stdin.gets end - task :_watch => prereq_task do + task :_watch => prereq_tasks do cmd = send(asset_type.to_s + "_cmd", watch=true, debug=true) if cmd.kind_of?(Array) cmd.each {|c| background_process(c)}