Class: Sprockets::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Includes:
Sprockets::Rails::Utils
Defined in:
lib/sprockets/railtie.rb

Defined Under Namespace

Classes: ManifestNeededError, OrderedOptions

Constant Summary collapse

LOOSE_APP_ASSETS =
lambda do |logical_path, filename|
  filename.start_with?(::Rails.root.join("app/assets").to_s) &&
  !['.js', '.css', ''].include?(File.extname(logical_path))
end

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Sprockets::Rails::Utils

#using_sprockets4?

Class Method Details

.build_manifest(app) ⇒ Object



213
214
215
216
217
# File 'lib/sprockets/railtie.rb', line 213

def self.build_manifest(app)
  config = app.config
  path = File.join(config.paths['public'].first, config.assets.prefix)
  Sprockets::Manifest.new(app.assets, path, config.assets.manifest)
end

Instance Method Details

#build_environment(app, initialized = nil) ⇒ Object



182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
# File 'lib/sprockets/railtie.rb', line 182

def build_environment(app, initialized = nil)
  initialized = app.initialized? if initialized.nil?
  unless initialized
    ::Rails.logger.warn "Application uninitialized: Try calling YourApp::Application.initialize!"
  end

  env = Sprockets::Environment.new(app.root.to_s)

  config = app.config

  # Run app.assets.configure blocks
  config.assets._blocks.each do |block|
    block.call(env)
  end

  # Set compressors after the configure blocks since they can
  # define new compressors and we only accept existent compressors.
  env.js_compressor  = config.assets.js_compressor
  env.css_compressor = config.assets.css_compressor

  # No more configuration changes at this point.
  # With cache classes on, Sprockets won't check the FS when files
  # change. Preferable in production when the FS only changes on
  # deploys when the app restarts.
  if config.cache_classes
    env = env.cached
  end

  env
end