# frozen_string_literal: true # Public: Allows to render HTML tags for scripts and styles processed by Vite. module ViteRails::TagHelpers # Public: Renders a script tag for vite/client to enable HMR in development. def vite_client_tag return unless src = vite_manifest.vite_client_src tag.script(src: src, type: 'module') end # Public: Renders a script tag to enable HMR with React Refresh. def vite_react_refresh_tag vite_manifest.react_refresh_preamble&.html_safe end # Public: Resolves the path for the specified Vite asset. # # Example: # <%= vite_asset_path 'calendar.css' %> # => "/vite/assets/calendar-1016838bab065ae1e122.css" def vite_asset_path(name, **options) path_to_asset vite_manifest.path_for(name, **options) end # Public: Resolves the url for the specified Vite asset. # # Example: # <%= vite_asset_url 'calendar.css' %> # => "https://example.com/vite/assets/calendar-1016838bab065ae1e122.css" def vite_asset_url(name, **options) url_to_asset vite_manifest.path_for(name, **options) end # Public: Renders a