@@ -64,35 +64,31 @@ def configure(&block)
6464 config . assets . digest = true
6565 config . assets . cache_limit = 50 . megabytes
6666
67- rake_tasks do |app |
68- require 'sprockets/rails/task'
69- Sprockets ::Rails ::Task . new ( app )
67+ config . assets . configure do |env |
68+ config . assets . paths . each { |path | env . append_path ( path ) }
7069 end
7170
72- def build_environment ( app , initialized = nil )
73- initialized = app . initialized? if initialized . nil?
74- unless initialized
75- ::Rails . logger . warn "Application uninitialized: Try calling YourApp::Application.initialize!"
76- end
77-
78- config = app . config
79- env = Sprockets ::Environment . new ( app . root . to_s )
80-
81- # Copy config.assets.paths to Sprockets
82- config . assets . paths . each do |path |
83- env . append_path path
84- end
85-
71+ config . assets . configure do |env |
8672 env . js_compressor = config . assets . js_compressor
8773 env . css_compressor = config . assets . css_compressor
74+ end
8875
89- env . context_class . class_eval do
90- include ::Sprockets ::Rails ::Context
91- self . assets_prefix = config . assets . prefix
92- self . digest_assets = config . assets . digest
93- self . config = config . action_controller
94- end
76+ config . assets . configure do |env |
77+ env . context_class . send :include , ::Sprockets ::Rails ::Context
78+ env . context_class . assets_prefix = config . assets . prefix
79+ env . context_class . digest_assets = config . assets . digest
80+ env . context_class . config = config . action_controller
81+ end
82+
83+ config . assets . configure do |env |
84+ env . cache = Sprockets ::Cache ::FileStore . new (
85+ "#{ env . root } /tmp/cache" ,
86+ config . assets . cache_limit ,
87+ env . logger
88+ )
89+ end
9590
91+ config . assets . configure do |env |
9692 # Configuration options that should invalidate
9793 # the Sprockets cache when changed.
9894 env . version = [
@@ -102,19 +98,31 @@ def build_environment(app, initialized = nil)
10298 ( config . action_controller . asset_host unless config . action_controller . asset_host . respond_to? ( :call ) ) ,
10399 Sprockets ::Rails ::VERSION
104100 ] . compact . join ( '-' )
101+ end
102+
103+ rake_tasks do |app |
104+ require 'sprockets/rails/task'
105+ Sprockets ::Rails ::Task . new ( app )
106+ end
107+
108+ def build_environment ( app , initialized = nil )
109+ initialized = app . initialized? if initialized . nil?
110+ unless initialized
111+ ::Rails . logger . warn "Application uninitialized: Try calling YourApp::Application.initialize!"
112+ end
105113
106- env . cache = Sprockets ::Cache :: FileStore . new ( " #{ app . root } /tmp/cache" , config . assets . cache_limit , env . logger )
114+ env = Sprockets ::Environment . new ( app . root . to_s )
107115
108116 # Run app.assets.configure blocks
109- config . assets . _blocks . each do |block |
117+ app . config . assets . _blocks . each do |block |
110118 block . call ( env )
111119 end
112120
113121 # No more configuration changes at this point.
114122 # With cache classes on, Sprockets won't check the FS when files
115123 # change. Preferable in production when the FS only changes on
116124 # deploys when the app restarts.
117- if config . cache_classes
125+ if app . config . cache_classes
118126 env = env . cached
119127 end
120128
0 commit comments