diff options
author | José Valim <jose.valim@gmail.com> | 2011-06-29 09:39:41 -0300 |
---|---|---|
committer | José Valim <jose.valim@gmail.com> | 2011-06-29 09:41:16 -0300 |
commit | c690b7124d2f2206342d11aebb7aa3fc990046d2 (patch) | |
tree | 1d4e0bc6a60c46ae7e2e6fed8965320ed997f208 /actionpack/lib | |
parent | 4106245530bc573c035fe70e8fc8633e89741abd (diff) | |
download | rails-c690b7124d2f2206342d11aebb7aa3fc990046d2.tar.gz rails-c690b7124d2f2206342d11aebb7aa3fc990046d2.tar.bz2 rails-c690b7124d2f2206342d11aebb7aa3fc990046d2.zip |
[IMPORTANT] Make "sprockets/railtie" require explicit.
This makes "sprockets/railtie" explicit. This means that sprockets will
be loaded when you require "rails/all". If you are not using requiring
"rails/all", you need to manually load it with all other framework
railties.
In order to be complete, this commit also adds --skip-sprockets to
the rails generator.
Diffstat (limited to 'actionpack/lib')
-rw-r--r-- | actionpack/lib/action_controller/railtie.rb | 1 | ||||
-rw-r--r-- | actionpack/lib/sprockets/assets.rake | 26 | ||||
-rw-r--r-- | actionpack/lib/sprockets/railtie.rb | 5 |
3 files changed, 31 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index d2ba052c8d..f0c29825ba 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -4,7 +4,6 @@ require "action_dispatch/railtie" require "action_view/railtie" require "abstract_controller/railties/routes_helpers" require "action_controller/railties/paths" -require "sprockets/railtie" module ActionController class Railtie < Rails::Railtie diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake new file mode 100644 index 0000000000..0236350576 --- /dev/null +++ b/actionpack/lib/sprockets/assets.rake @@ -0,0 +1,26 @@ +namespace :assets do + desc "Compile all the assets named in config.assets.precompile" + task :precompile do + if ENV["RAILS_GROUPS"].to_s.empty? + ENV["RAILS_GROUPS"] = "assets" + Kernel.exec $0, *ARGV + else + Rake::Task["environment"].invoke + Sprockets::Helpers::RailsHelper + + assets = Rails.application.config.assets.precompile + Rails.application.assets.precompile(*assets) + end + end + + desc "Remove compiled assets" + task :clean => :environment do + assets = Rails.application.config.assets + public_asset_path = Rails.public_path + assets.prefix + file_list = FileList.new("#{public_asset_path}/**/*") + file_list.each do |file| + rm_rf file + rm_rf "#{file}.gz" + end + end +end diff --git a/actionpack/lib/sprockets/railtie.rb b/actionpack/lib/sprockets/railtie.rb index ab5101f6fc..1535716fb9 100644 --- a/actionpack/lib/sprockets/railtie.rb +++ b/actionpack/lib/sprockets/railtie.rb @@ -1,6 +1,7 @@ module Sprockets autoload :Helpers, "sprockets/helpers" + # TODO: Get rid of config.assets.enabled class Railtie < ::Rails::Railtie def self.using_coffee? require 'coffee-script' @@ -11,6 +12,10 @@ module Sprockets config.app_generators.javascript_engine :coffee if using_coffee? + rake_tasks do + load "sprockets/assets.rake" + end + # Configure ActionController to use sprockets. initializer "sprockets.set_configs", :after => "action_controller.set_configs" do |app| ActiveSupport.on_load(:action_controller) do |