Skip to content

Commit

Permalink
Merge pull request #226 from rails/recycle-cached-env-for-precompiled…
Browse files Browse the repository at this point in the history
…-assets

Perf: ensure same cached environment is used for precompiled_assets
  • Loading branch information
josh committed Feb 11, 2015
2 parents fdb0df6 + 6a4bcd5 commit 0159123
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion lib/sprockets/rails/helper.rb
Expand Up @@ -219,7 +219,24 @@ def lookup_asset_for_path(path, options = {})

# Internal: Generate a Set of all precompiled assets.
def precompiled_assets
@precompiled_assets ||= Set.new(assets_manifest.find(assets_precompile || []))
@precompiled_assets ||= begin
assets = Set.new

filters = (assets_precompile || []).map { |f|
Sprockets::Manifest.compile_match_filter(f)
}

env = assets_environment
env.logical_paths do |logical_path, filename|
if filters.any? { |f| f.call(logical_path, filename) }
env.find_all_linked_assets(filename) do |asset|
assets << asset
end
end
end

assets
end
end
end
end
Expand Down

0 comments on commit 0159123

Please sign in to comment.