Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions vite_rails/lib/vite_rails/tag_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,15 @@ def vite_manifest

# Internal: Renders a modulepreload link tag.
def vite_preload_tag(*sources, crossorigin:, **options)
sources.map { |source|
href = path_to_asset(source)
try(:request).try(:send_early_hints, 'Link' => %(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin }))
asset_paths = sources.map { | source | path_to_asset(source) }
Comment thread
PikachuEXE marked this conversation as resolved.
Outdated
try(:request).try(
:send_early_hints,
'Link' => asset_paths.map do |href|
%(<#{ href }>; rel=modulepreload; as=script; crossorigin=#{ crossorigin })
end.join("\n"),
)
asset_paths.map do |href|
tag.link(rel: 'modulepreload', href: href, as: 'script', crossorigin: crossorigin, **options)
}.join("\n").html_safe
end.join("\n").html_safe
Comment thread
PikachuEXE marked this conversation as resolved.
Outdated
end
end