Sha256: 2baaed92a9aaa08f1d4a8e3f8b421467fabdd8d0cf75ee74d4058f5710fb63fa

Contents?: true

Size: 799 Bytes

Versions: 4

Compression:

Stored size: 799 Bytes

Contents

# frozen_string_literal: true

module ViteHelpers
  def vite_client_tag
    src = vite_manifest.vite_client_src || "/vite-dev/@vite/client"
    script(src:, type: :module)
  end

  def vite_javascript_tag(
    *names,
    type: :module,
    asset_type: :javascript,
    crossorigin: :anonymous,
    **options
  )
    entries = vite_manifest.resolve_entries(*names, type: asset_type)
    entries.fetch(:scripts).each do |src|
      script(
        src:,
        type:,
        crossorigin:,
        extname: :js,
        **options
      )
    end
    entries.fetch(:stylesheets).each do |href|
      link(href:, rel: :stylesheet, type: "text/css")
    end
  end

  def vite_manifest
    ViteRuby.instance.manifest
  end

  def vite_asset_path(name, **)
    vite_manifest.path_for(name, **)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
staticky-0.3.0 site_template/lib/vite_helpers.rb
staticky-0.2.0 site_template/lib/vite_helpers.rb
staticky-0.1.1 site_template/lib/vite_helpers.rb
staticky-0.1.0 site_template/lib/vite_helpers.rb