Class: Webpack::Rails::Manifest

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

Overview

Webpack manifest loading, caching & entry point retrieval

Defined Under Namespace

Classes: EntryPointMissingError, ManifestLoadError, WebpackError

Class Method Summary collapse

Class Method Details

.asset_paths(source) ⇒ Object

:nodoc:

Raises:



28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/webpack/rails/manifest.rb', line 28

def asset_paths(source)
  raise WebpackError, manifest["errors"] unless manifest_bundled?

  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.webpack.public_path}/#{p}"
    end
  else
    raise EntryPointMissingError, "Can't find entry point '#{source}' in webpack manifest"
  end
end