2011-03-21 19:05:56 -04:00
|
|
|
namespace :assets do
|
2011-04-18 05:18:37 -04:00
|
|
|
desc "Compile all the assets named in config.assets.precompile"
|
2011-08-14 13:52:46 -04:00
|
|
|
task :precompile do
|
|
|
|
# We need to do this dance because RAILS_GROUPS is used
|
|
|
|
# too early in the boot process and changing here is already too late.
|
2011-08-15 14:31:47 -04:00
|
|
|
if ENV["RAILS_GROUPS"].to_s.empty? || ENV["RAILS_ENV"].to_s.empty?
|
|
|
|
ENV["RAILS_GROUPS"] ||= "assets"
|
|
|
|
ENV["RAILS_ENV"] ||= "production"
|
2011-08-14 13:52:46 -04:00
|
|
|
Kernel.exec $0, *ARGV
|
|
|
|
else
|
|
|
|
Rake::Task["environment"].invoke
|
|
|
|
Sprockets::Helpers::RailsHelper
|
2011-04-19 14:06:09 -04:00
|
|
|
|
2011-08-14 13:52:46 -04:00
|
|
|
assets = Rails.application.config.assets.precompile
|
|
|
|
# Always perform caching so that asset_path appends the timestamps to file references.
|
|
|
|
Rails.application.config.action_controller.perform_caching = true
|
|
|
|
Rails.application.assets.precompile(*assets)
|
|
|
|
end
|
2011-03-21 19:05:56 -04:00
|
|
|
end
|
2011-05-27 03:29:54 -04:00
|
|
|
|
|
|
|
desc "Remove compiled assets"
|
2011-08-04 19:17:03 -04:00
|
|
|
task :clean => [:environment, 'tmp:cache:clear'] do
|
2011-05-27 03:29:54 -04:00
|
|
|
assets = Rails.application.config.assets
|
|
|
|
public_asset_path = Rails.public_path + assets.prefix
|
2011-07-16 18:44:00 -04:00
|
|
|
rm_rf public_asset_path, :secure => true
|
2011-05-27 03:29:54 -04:00
|
|
|
end
|
2011-08-15 14:31:47 -04:00
|
|
|
end
|