Permalink
Browse files

Add sprockets task to compile assets

  • Loading branch information...
1 parent 3e7985c commit 77ad4ca058c9a845257cbeb58a84cf511bae1040 @josh josh committed Mar 21, 2011
Showing with 17 additions and 1 deletion.
  1. +3 −1 railties/lib/rails/application/configuration.rb
  2. +14 −0 railties/lib/rails/tasks/assets.rake
@@ -9,7 +9,8 @@ class Configuration < ::Rails::Engine::Configuration
:filter_parameters, :helpers_paths, :logger,
:preload_frameworks, :reload_plugins,
:secret_token, :serve_static_assets, :session_options,
- :time_zone, :whiny_nils
+ :time_zone, :whiny_nils,
+ :compile_assets
attr_writer :log_level
@@ -28,6 +29,7 @@ def initialize(*)
@log_level = nil
@middleware = app_middleware
@generators = app_generators
+ @compile_assets = []
end
def compiled_asset_path
@@ -0,0 +1,14 @@
+namespace :assets do
+ task :compile => :environment do
+ env = Rails.application.assets
+
+ assets = Rails.root.join("public/assets")
+ assets.mkdir unless assets.exist?
+
+ Rails.application.config.compile_assets.each do |path|
+ assets.join(path).open('w') do |f|
+ f.write env[path].to_s
+ end
+ end
+ end
+end

0 comments on commit 77ad4ca

Please sign in to comment.