Class: Sprockets::Railtie

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

Defined Under Namespace

Classes: OrderedOptions

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.build_manifest(app) ⇒ Object


133
134
135
136
137
# File 'lib/sprockets/railtie.rb', line 133

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


109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/sprockets/railtie.rb', line 109

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)

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

  # 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 app.config.cache_classes
    env = env.cached
  end

  env
end