Class: Repack::Manifest

Inherits:
Object
  • Object
show all
Defined in:
lib/repack/manifest.rb

Overview

Webpack manifest loading, caching & entry point retrieval

Defined Under Namespace

Classes: EntryPointMissingError, ManifestLoadError

Class Method Summary collapse

Class Method Details

.asset_paths(source) ⇒ Object

:nodoc:



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/repack/manifest.rb', line 20

def asset_paths(source)
  paths = manifest["assetsByChunkName"][source]
  if paths
    # Can be either a string or an array of strings.
    # Do not include source maps as they are not javascript
    [paths].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
      "/#{::Rails.configuration.repack.public_path}/#{p}"
    end
  else
    raise EntryPointMissingError, "Can't find entry point '#{source}' in webpack manifest"
  end
end