Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'andyjeffries/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
pboling committed Aug 13, 2013
2 parents cbfc760 + c1a5729 commit f802f31
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions lib/requirejs/rails/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,26 @@ class Engine < ::Rails::Engine
end
end

initializer "requirejs.manifest", :after => "sprockets.environment" do |app|
config = app.config
if config.requirejs.manifest_path.exist? && config.assets.digests
rjs_digests = YAML.load(ERB.new(File.new(config.requirejs.manifest_path).read).result)
config.assets.digests.merge!(rjs_digests)
if ::Rails::VERSION::STRING >= "4.0.0"
config.after_initialize do |app|
config = app.config
rails_manifest_path = File.join(app.root, 'public', config.assets.prefix)
rails_manifest = Sprockets::Manifest.new(app.assets, rails_manifest_path)
if config.requirejs.manifest_path.exist? && rails_manifest
rjs_digests = YAML.load(ERB.new(File.new(config.requirejs.manifest_path).read).result)
rails_manifest.assets.merge!(rjs_digests)
ActionView::Base.instance_eval do
self.assets_manifest = rails_manifest
end
end
end
else
initializer "requirejs.manifest", :after => "sprockets.environment" do |app|
config = app.config
if config.requirejs.manifest_path.exist? && config.assets.digests
rjs_digests = YAML.load(ERB.new(File.new(config.requirejs.manifest_path).read).result)
config.assets.digests.merge!(rjs_digests)
end
end
end

Expand Down

0 comments on commit f802f31

Please sign in to comment.