diff --git a/test/helper_test.rb b/test/helper_test.rb index deadb3b3..4ec629d3 100644 --- a/test/helper_test.rb +++ b/test/helper_test.rb @@ -105,6 +105,14 @@ def test_vite_stylesheet_tag } end + def test_vite_preload_tag + assert_includes vite_typescript_tag('main', host: 'example.com', protocol: 'https'), [ + %(), + %(), + %(), + ].join("\n") + end + def test_vite_javascript_tag assert_similar [ %(), diff --git a/vite_rails/lib/vite_rails/tag_helpers.rb b/vite_rails/lib/vite_rails/tag_helpers.rb index f6f5e9cc..066d8c7f 100644 --- a/vite_rails/lib/vite_rails/tag_helpers.rb +++ b/vite_rails/lib/vite_rails/tag_helpers.rb @@ -101,7 +101,8 @@ def vite_manifest # Internal: Renders a modulepreload link tag. def vite_preload_tag(*sources, crossorigin:, **options) - asset_paths = sources.map { |source| path_to_asset(source) } + url_options = options.extract!(:host, :protocol) + asset_paths = sources.map { |source| path_to_asset(source, **url_options) } try(:request).try( :send_early_hints, 'Link' => asset_paths.map { |href|