Class: SewingKit::Webpack::Manifest::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/sewing_kit/webpack/manifest/base.rb

Direct Known Subclasses

Development, Production, TestWithNoAssets

Instance Method Summary collapse

Constructor Details

#initializeBase

Returns a new instance of Base.



9
10
11
# File 'lib/sewing_kit/webpack/manifest/base.rb', line 9

def initialize
  @metadata = nil
end

Instance Method Details

#clear_cache!Object



13
14
15
# File 'lib/sewing_kit/webpack/manifest/base.rb', line 13

def clear_cache!
  @metadata = nil
end

#manifestObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/sewing_kit/webpack/manifest/base.rb', line 17

def manifest
   = 

  if .is_a?(Array)
    all_assets = .flat_map do |data|
      data["assets"]["all"].values
    end

    # sewing-kit asset manifests return a numerically indexed hash, not a true array,
    # so we need to change it back to a hash for compatibility
    asset_hash = all_assets.each_with_index
      .collect { |asset, index| [index, asset] }
      .to_h

    {
      "all" => asset_hash,
    }
  else
    ["assets"]
  end
end