Sha256: 2d8ad1f19a5ea2a80469acd5c9802328d2c6881682ffa119cdcd50f7e1953ad9

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# Singleton registry for accessing the packs path using generated manifest.
# This allows javascript_pack_tag, stylesheet_pack_tag, asset_pack_path to take a reference to,
# say, "calendar.js" or "calendar.css" and turn it into "/packs/calendar.js" or
# "/packs/calendar.css" in development. In production mode, it returns compiles
# files, # "/packs/calendar-1016838bab065ae1e314.js" and
# "/packs/calendar-1016838bab065ae1e314.css" for long-term caching

require "webpacker_lite/file_loader"
require "webpacker_lite/env"
require "webpacker_lite/configuration"

class WebpackerLite::Manifest < WebpackerLite::FileLoader
  class << self
    def file_path
      WebpackerLite::Configuration.manifest_path
    end

    def lookup(name)
      load if WebpackerLite::Env.development? || instance.data.empty?
      raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Manifest.load must be called first") unless instance
      instance.data[name.to_s] || raise(WebpackerLite::FileLoader::NotFoundError.new("Can't find #{name} in #{file_path}. Is webpack still compiling?"))
    end
  end

  private
    def load
      return super unless File.exist?(@path)
      JSON.parse(File.read(@path))
    end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webpacker_lite-1.0.0 lib/webpacker_lite/manifest.rb