Skip to content

Commit

Permalink
Merge pull request #215 from rails/init-append-assets-path
Browse files Browse the repository at this point in the history
Import append_assets_path initializer
  • Loading branch information
josh committed Jan 21, 2015
2 parents 187bdc1 + 550dee1 commit d9cdd77
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/sprockets/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,23 @@ def assets
# Returns Sprockets::Manifest for app config.
attr_accessor :assets_manifest
end

class Engine < Railtie
# Skip defining append_assets_path on Rails <= 4.2
unless initializers.find { |init| init.name == :append_assets_path }
initializer :append_assets_path, :group => :all do |app|
if paths["app/assets"].respond_to?(:existent_directories)
app.config.assets.paths.unshift(*paths["vendor/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["lib/assets"].existent_directories)
app.config.assets.paths.unshift(*paths["app/assets"].existent_directories)
else
app.config.assets.paths.unshift(*paths["vendor/assets"].paths.select { |d| File.directory?(d) })
app.config.assets.paths.unshift(*paths["lib/assets"].paths.select { |d| File.directory?(d) })
app.config.assets.paths.unshift(*paths["app/assets"].paths.select { |d| File.directory?(d) })
end
end
end
end
end

module Sprockets
Expand Down

0 comments on commit d9cdd77

Please sign in to comment.