Commit 185ab4c3 by Nate Hardison

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.
parent ea3506d2
...@@ -25,13 +25,6 @@ def preprocess_with_mako(filename) ...@@ -25,13 +25,6 @@ def preprocess_with_mako(filename)
end end
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) def xmodule_cmd(watch=false, debug=false)
xmodule_cmd = 'xmodule_assets common/static/xmodule' xmodule_cmd = 'xmodule_assets common/static/xmodule'
if watch if watch
...@@ -65,9 +58,6 @@ def coffee_cmd(watch=false, debug=false) ...@@ -65,9 +58,6 @@ def coffee_cmd(watch=false, debug=false)
end end
def sass_cmd(watch=false, debug=false) def sass_cmd(watch=false, debug=false)
# Make sure to preprocess templatized Sass first
preprocess_assets()
sass_load_paths = ["./common/static/sass"] sass_load_paths = ["./common/static/sass"]
sass_watch_paths = ["*/static"] sass_watch_paths = ["*/static"]
if USE_CUSTOM_THEME if USE_CUSTOM_THEME
...@@ -89,6 +79,13 @@ namespace :assets do ...@@ -89,6 +79,13 @@ namespace :assets do
desc "Compile all assets in debug mode" desc "Compile all assets in debug mode"
multitask :debug 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" desc "Watch all assets for changes and automatically recompile"
task :watch => 'assets:_watch' do task :watch => 'assets:_watch' do
puts "Press ENTER to terminate".red puts "Press ENTER to terminate".red
...@@ -97,9 +94,9 @@ namespace :assets do ...@@ -97,9 +94,9 @@ namespace :assets do
{:xmodule => :install_python_prereqs, {:xmodule => :install_python_prereqs,
:coffee => :install_node_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" 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) cmd = send(asset_type.to_s + "_cmd", watch=false, debug=false)
if cmd.kind_of?(Array) if cmd.kind_of?(Array)
cmd.each {|c| sh(c)} cmd.each {|c| sh(c)}
...@@ -114,7 +111,7 @@ namespace :assets do ...@@ -114,7 +111,7 @@ namespace :assets do
namespace asset_type do namespace asset_type do
desc "Compile all #{asset_type} assets in debug mode" 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) cmd = send(asset_type.to_s + "_cmd", watch=false, debug=true)
sh(cmd) sh(cmd)
end end
...@@ -125,7 +122,7 @@ namespace :assets do ...@@ -125,7 +122,7 @@ namespace :assets do
$stdin.gets $stdin.gets
end end
task :_watch => prereq_task do task :_watch => prereq_tasks do
cmd = send(asset_type.to_s + "_cmd", watch=true, debug=true) cmd = send(asset_type.to_s + "_cmd", watch=true, debug=true)
if cmd.kind_of?(Array) if cmd.kind_of?(Array)
cmd.each {|c| background_process(c)} cmd.each {|c| background_process(c)}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment