Avoid doing 2 lookups for a single stylesheet tag

This commit is contained in:
Renaud Chaput 2025-04-23 15:02:49 +02:00
parent 8d69312230
commit 4a418bb017
No known key found for this signature in database
GPG Key ID: BCFC859D49B46990

View File

@ -85,7 +85,11 @@ module ViteRails::TagHelpers::IntegrityExtension
def vite_stylesheet_tag(*names, **options)
''.html_safe.tap do |tags|
names.each do |name|
tags << super(name, integrity: vite_manifest.integrity_hash_for(name), **options)
entry = vite_manifest.path_and_integrity_for(name, type: :stylesheet)
options[:extname] = false if Rails::VERSION::MAJOR >= 7
tags << stylesheet_link_tag(entry[:path], integrity: entry[:integrity], **options)
end
end
end