Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (51 sloc) 2.0 kb
5711a35 @josevalim Ensure default_asset_host_protocol is respected, closes #2980.
josevalim authored
1 require "action_controller/railtie"
2
b6843f2 @josevalim Lazily load sprockets.
josevalim authored
3 module Sprockets
eb367af @josevalim `rake assets:precompile` loads the application but does not initialize i...
josevalim authored
4 autoload :Bootstrap, "sprockets/bootstrap"
5 autoload :Helpers, "sprockets/helpers"
038808b @guilleiguaran Add public API for register new js and css compressors for Sprockets
guilleiguaran authored
6 autoload :Compressors, "sprockets/compressors"
2f6e389 @josevalim Make compressors lazily load.
josevalim authored
7 autoload :LazyCompressor, "sprockets/compressors"
8 autoload :NullCompressor, "sprockets/compressors"
857d20e @guilleiguaran Move precompile task to Sprockets::StaticCompiler
guilleiguaran authored
9 autoload :StaticCompiler, "sprockets/static_compiler"
9dabbd0 @wycats Make sure that Sprockets::Helpers::RailsHelper can be found
wycats authored
10
c690b71 @josevalim [IMPORTANT] Make "sprockets/railtie" require explicit.
josevalim authored
11 # TODO: Get rid of config.assets.enabled
9dabbd0 @wycats Make sure that Sprockets::Helpers::RailsHelper can be found
wycats authored
12 class Railtie < ::Rails::Railtie
c690b71 @josevalim [IMPORTANT] Make "sprockets/railtie" require explicit.
josevalim authored
13 rake_tasks do
14 load "sprockets/assets.rake"
15 end
16
d68884f @josevalim :group => :assets should only run in the assets environment.
josevalim authored
17 initializer "sprockets.environment", :group => :all do |app|
8248052 @josh Make Rails.application.assets available in initializers
josh authored
18 config = app.config
19 next unless config.assets.enabled
b6843f2 @josevalim Lazily load sprockets.
josevalim authored
20
8248052 @josh Make Rails.application.assets available in initializers
josh authored
21 require 'sprockets'
22
23 app.assets = Sprockets::Environment.new(app.root.to_s) do |env|
63d3809 @josh Fix sprockets warnings
josh authored
24 env.version = ::Rails.env + "-#{config.assets.version}"
8248052 @josh Make Rails.application.assets available in initializers
josh authored
25
226783d @guilleiguaran Silent Sprockets logger when config.assets.logger is set to false
guilleiguaran authored
26 if config.assets.logger != false
27 env.logger = config.assets.logger || ::Rails.logger
28 end
29
8248052 @josh Make Rails.application.assets available in initializers
josh authored
30 if config.assets.cache_store != false
31 env.cache = ActiveSupport::Cache.lookup_store(config.assets.cache_store) || ::Rails.cache
32 end
33 end
a19c260 @josevalim Include modules to the context in the railtie.
josevalim authored
34
d0b3937 @guilleiguaran Set default location of manifest with config.assets.manifest
guilleiguaran authored
35 if config.assets.manifest
36 path = File.join(config.assets.manifest, "manifest.yml")
37 else
38 path = File.join(Rails.public_path, config.assets.prefix, "manifest.yml")
39 end
40
41 if File.exist?(path)
f236e00 @guilleiguaran Backport f443f9cb0c64 to master
guilleiguaran authored
42 config.assets.digests = YAML.load_file(path)
dffdd82 @guilleiguaran Read digests of assets from manifest.yml if config.assets.manifest is on
guilleiguaran authored
43 end
44
a19c260 @josevalim Include modules to the context in the railtie.
josevalim authored
45 ActiveSupport.on_load(:action_view) do
00be5bd Remaining cleanup from changes to AssetTagHelper
tomhuda authored
46 include ::Sprockets::Helpers::RailsHelper
4cea4ee @josevalim Fix regression when calling helpers inside sprockets.
josevalim authored
47 app.assets.context_class.instance_eval do
48 include ::Sprockets::Helpers::IsolatedHelper
49 include ::Sprockets::Helpers::RailsHelper
50 end
a19c260 @josevalim Include modules to the context in the railtie.
josevalim authored
51 end
8f75c3a @josevalim Move app initializers to sprockets railtie.
josevalim authored
52 end
53
8248052 @josh Make Rails.application.assets available in initializers
josh authored
54 # We need to configure this after initialization to ensure we collect
55 # paths from all engines. This hook is invoked exactly before routes
56 # are compiled, and so that other Railties have an opportunity to
57 # register compressors.
58 config.after_initialize do |app|
eb367af @josevalim `rake assets:precompile` loads the application but does not initialize i...
josevalim authored
59 Sprockets::Bootstrap.new(app).run
8248052 @josh Make Rails.application.assets available in initializers
josh authored
60 end
8f75c3a @josevalim Move app initializers to sprockets railtie.
josevalim authored
61 end
84f1b83 @josh Only include SprocketsHelper into assets context
josh authored
62 end
Something went wrong with that request. Please try again.