Class: Sprockets::Railtie

Inherits:
Rails::Railtie
  • Object
show all
Includes:
Sprockets::Rails::Utils
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) &&
    !['.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



163
164
165
166
167
# File 'lib/sprockets/railtie.rb', line 163

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



132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# File 'lib/sprockets/railtie.rb', line 132

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