Skip to content

Commit 642c178

Browse files
authored
feat: allow options to be passed to legacy helpers (#474)
1 parent b92ef4b commit 642c178

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

vite_plugin_legacy/lib/vite_plugin_legacy/tag_helpers.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@
44
module VitePluginLegacy::TagHelpers
55
# Public: Renders a <script> tag for the specified Vite entrypoints when using
66
# @vitejs/plugin-legacy, which injects polyfills.
7-
def vite_legacy_javascript_tag(name, asset_type: :javascript)
7+
def vite_legacy_javascript_tag(name, asset_type: :javascript, **options)
88
return if ViteRuby.instance.dev_server_running?
99

1010
legacy_name = name.sub(/(\..+)|$/, '-legacy\1')
11-
import_tag = content_tag(:script, nomodule: true) {
11+
import_tag = content_tag(:script, nomodule: true, **options) {
1212
"System.import('#{vite_asset_path(legacy_name, type: asset_type)}')".html_safe
1313
}
1414

15-
safe_join [vite_legacy_polyfill_tag, import_tag]
15+
safe_join [vite_legacy_polyfill_tag(**options), import_tag]
1616
end
1717

1818
# Public: Same as `vite_legacy_javascript_tag`, but for TypeScript entries.
19-
def vite_legacy_typescript_tag(name)
20-
vite_legacy_javascript_tag(name, asset_type: :typescript)
19+
def vite_legacy_typescript_tag(name, **options)
20+
vite_legacy_javascript_tag(name, asset_type: :typescript, **options)
2121
end
2222

2323
# Internal: Renders the vite-legacy-polyfill to enable code splitting in
2424
# browsers that do not support modules.
25-
def vite_legacy_polyfill_tag
25+
def vite_legacy_polyfill_tag(**options)
2626
return if ViteRuby.instance.dev_server_running?
2727

28-
content_tag(:script, nil, nomodule: true, src: vite_asset_path("legacy-polyfills", type: :virtual))
28+
content_tag(:script, nil, nomodule: true, src: vite_asset_path("legacy-polyfills", type: :virtual), **options)
2929
end
3030
end

0 commit comments

Comments
 (0)