Class: Gitlab::Webpack::Manifest

Inherits:
Object
  • Object
show all
Extended by:
Utils::StrongMemoize
Defined in:
lib/gitlab/webpack/manifest.rb

Defined Under Namespace

Classes: ManifestLoadError, WebpackError

Constant Summary collapse

AssetMissingError =

Raised if a supplied entry point does not exist in the webpack manifest

Class.new(StandardError)

Class Method Summary collapse

Class Method Details

.asset_paths(source) ⇒ Object

Raises:



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/gitlab/webpack/manifest.rb', line 42

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

.clear_manifest!Object



57
58
59
# File 'lib/gitlab/webpack/manifest.rb', line 57

def clear_manifest!
  clear_memoization(:manifest)
end

.entrypoint_paths(source) ⇒ Object

Raises:



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

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

  dll_assets = manifest.fetch("dllAssets", [])
  entrypoint = manifest["entrypoints"][source]
  if entrypoint && entrypoint["assets"]
    # Can be either a string or an array of strings.
    # Do not include source maps as they are not javascript
    [dll_assets, entrypoint["assets"]].flatten.reject { |p| p =~ /.*\.map$/ }.map do |p|
      "/#{Gitlab.config.webpack.public_path}/#{p}"
    end
  else
    raise AssetMissingError, "Can't find asset '#{source}' in webpack manifest"
  end
end