Module: InertiaHanami::AssetVersion

Defined in:
lib/inertia_hanami/asset_version.rb

Overview

Derives an Inertia asset version string from hanami-assets' assets.json manifest, mirroring the role ViteRuby.digest plays for inertia-rails.

Constant Summary collapse

MANIFEST_FILENAME =
"assets.json"

Class Method Summary collapse

Class Method Details

.digest(assets_root) ⇒ Object

Returns a SHA256 hex digest of the assets.json manifest under assets_root, or nil if no manifest is present (e.g. assets not yet compiled).



14
15
16
17
18
19
20
21
# File 'lib/inertia_hanami/asset_version.rb', line 14

def self.digest(assets_root)
  return nil if assets_root.nil?

  manifest_path = Pathname(assets_root).join(MANIFEST_FILENAME)
  return nil unless manifest_path.file?

  Digest::SHA256.file(manifest_path).hexdigest
end