class Webpacker::Manifest

the webpacker.yml file, any lookups will be preceded by a compilation if one is needed.
When the configuration is set to on-demand compilation, with the ‘compile: true` option in
“/packs/calendar-1016838bab065ae1e314.css”.
say, “calendar.js” or “calendar.css” and turn it into “/packs/calendar-1016838bab065ae1e314.js” or
This allows javascript_pack_tag, stylesheet_pack_tag, asset_pack_path to take a reference to,
Singleton registry for accessing the packs path using a generated manifest.

def compile

def compile
  Webpacker.logger.tagged("Webpacker") { compiler.compile }
end

def compiling?

def compiling?
  config.compile? && !dev_server.running?
end

def data

def data
  if config.cache_manifest?
    @data ||= load
  else
    refresh
  end
end

def find(name)

def find(name)
  data[name.to_s].presence
end

def full_pack_name(name, pack_type)

def full_pack_name(name, pack_type)
  return name unless File.extname(name.to_s).empty?
  "#{name}.#{manifest_type(pack_type)}"
end

def handle_missing_entry(name, pack_type)

def handle_missing_entry(name, pack_type)
  raise Webpacker::Manifest::MissingEntryError, missing_file_from_manifest_error(full_pack_name(name, pack_type[:type]))
end

def initialize(webpacker)

def initialize(webpacker)
  @webpacker = webpacker
end

def load

def load
  if config.public_manifest_path.exist?
    JSON.parse config.public_manifest_path.read
  else
    {}
  end
end

def lookup(name, pack_type = {})

Webpacker.manifest.lookup('calendar.js') # => "/packs/calendar-1016838bab065ae1e122.js"

Example:

If no asset is found, returns nil.
Computes the relative path for a given Webpacker asset using manifest.json.
def lookup(name, pack_type = {})
  compile if compiling?
  find(full_pack_name(name, pack_type[:type]))
end

def lookup!(name, pack_type = {})

Like lookup, except that if no asset is found, raises a Webpacker::Manifest::MissingEntryError.
def lookup!(name, pack_type = {})
  lookup(name, pack_type) || handle_missing_entry(name, pack_type)
end

def lookup_pack_with_chunks(name, pack_type = {})

def lookup_pack_with_chunks(name, pack_type = {})
  compile if compiling?
  manifest_pack_type = manifest_type(pack_type[:type])
  manifest_pack_name = manifest_name(name, manifest_pack_type)
  find("entrypoints")[manifest_pack_name][manifest_pack_type]
rescue NoMethodError
  nil
end

def lookup_pack_with_chunks!(name, pack_type = {})

def lookup_pack_with_chunks!(name, pack_type = {})
  lookup_pack_with_chunks(name, pack_type) || handle_missing_entry(name, pack_type)
end

def manifest_name(name, pack_type)

When the user provides a name with a file extension, we want to try to strip it off.
manifest hash the entrypoints are defined by their pack name without the extension.
The `manifest_name` method strips of the file extension of the name, because in the
def manifest_name(name, pack_type)
  return name if File.extname(name.to_s).empty?
  File.basename(name, pack_type)
end

def manifest_type(pack_type)

def manifest_type(pack_type)
  case pack_type
  when :javascript then "js"
  when :stylesheet then "css"
  else pack_type.to_s
  end
end

def missing_file_from_manifest_error(bundle_name)

def missing_file_from_manifest_error(bundle_name)
  <<-MSG
acker can't find #{bundle_name} in #{config.public_manifest_path}. Possible causes:
ou want to set webpacker.yml value of compile to true for your environment
nless you are using the `webpack -w` or the webpack-dev-server.
ebpack has not yet re-run to reflect updates.
ou have misconfigured Webpacker's config/webpacker.yml file.
our webpack configuration is not creating a manifest.
 manifest contains:
ON.pretty_generate(@data)}
  MSG
end

def refresh

def refresh
  @data = load
end