|
4 | 4 | module VitePluginLegacy::TagHelpers
|
5 | 5 | # Public: Renders a <script> tag for the specified Vite entrypoints when using
|
6 | 6 | # @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) |
8 | 8 | return if ViteRuby.instance.dev_server_running?
|
9 | 9 |
|
10 | 10 | legacy_name = name.sub(/(\..+)|$/, '-legacy\1')
|
11 |
| - import_tag = content_tag(:script, nomodule: true) { |
| 11 | + import_tag = content_tag(:script, nomodule: true, **options) { |
12 | 12 | "System.import('#{vite_asset_path(legacy_name, type: asset_type)}')".html_safe
|
13 | 13 | }
|
14 | 14 |
|
15 |
| - safe_join [vite_legacy_polyfill_tag, import_tag] |
| 15 | + safe_join [vite_legacy_polyfill_tag(**options), import_tag] |
16 | 16 | end
|
17 | 17 |
|
18 | 18 | # 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) |
21 | 21 | end
|
22 | 22 |
|
23 | 23 | # Internal: Renders the vite-legacy-polyfill to enable code splitting in
|
24 | 24 | # browsers that do not support modules.
|
25 |
| - def vite_legacy_polyfill_tag |
| 25 | + def vite_legacy_polyfill_tag(**options) |
26 | 26 | return if ViteRuby.instance.dev_server_running?
|
27 | 27 |
|
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) |
29 | 29 | end
|
30 | 30 | end
|
0 commit comments