Sha256: 851fbdeded18ac50a7e05ffb7ac11553bedcb9b657cc9c5a84d42fca44c48abe

Contents?: true

Size: 1.71 KB

Versions: 16

Compression:

Stored size: 1.71 KB

Contents

class Webpacker::Configuration
  delegate :root_path, :config_path, :env, to: :@webpacker

  def initialize(webpacker)
    @webpacker = webpacker
  end

  def refresh
    @data = load
  end

  def dev_server
    fetch(:dev_server)
  end

  def compile?
    fetch(:compile)
  end

  def source_path
    root_path.join(fetch(:source_path))
  end

  def resolved_paths
    fetch(:resolved_paths)
  end

  def resolved_paths_globbed
    resolved_paths.map { |p| "#{p}/**/*" }
  end

  def source_entry_path
    source_path.join(fetch(:source_entry_path))
  end

  def public_path
    root_path.join("public")
  end

  def public_output_path
    public_path.join(fetch(:public_output_path))
  end

  def public_manifest_path
    public_output_path.join("manifest.json")
  end

  def cache_manifest?
    fetch(:cache_manifest)
  end

  def cache_path
    root_path.join(fetch(:cache_path))
  end

  def extensions
    fetch(:extensions)
  end

  private
    def fetch(key)
      data.fetch(key, defaults[key])
    end

    def data
      @data ||= load
    end

    def load
      YAML.load(config_path.read)[env].deep_symbolize_keys

    rescue Errno::ENOENT => e
      raise "Webpacker configuration file not found #{config_path}. " \
            "Please run rails webpacker:install " \
            "Error: #{e.message}"

    rescue Psych::SyntaxError => e
      raise "YAML syntax error occurred while parsing #{config_path}. " \
            "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
            "Error: #{e.message}"
    end

    def defaults
      @defaults ||= \
        HashWithIndifferentAccess.new(YAML.load_file(File.expand_path("../../install/config/webpacker.yml", __FILE__))[env])
    end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
webpacker-jets-3.2.101 lib/webpacker/configuration.rb
webpacker-jets-3.2.100 lib/webpacker/configuration.rb
webpacker-3.5.3 lib/webpacker/configuration.rb
webpacker-3.5.2 lib/webpacker/configuration.rb
webpacker-3.5.1 lib/webpacker/configuration.rb
webpacker-3.5.0 lib/webpacker/configuration.rb
webpacker-3.4.3 lib/webpacker/configuration.rb
webpacker-4.0.0.pre.pre.2 lib/webpacker/configuration.rb
webpacker-4.0.0.pre.pre.1 lib/webpacker/configuration.rb
webpacker-3.4.1 lib/webpacker/configuration.rb
webpacker-3.4.0 lib/webpacker/configuration.rb
webpacker-3.3.1 lib/webpacker/configuration.rb
webpacker-3.3.0 lib/webpacker/configuration.rb
webpacker-3.2.2 lib/webpacker/configuration.rb
webpacker-3.2.1 lib/webpacker/configuration.rb
webpacker-3.2.0 lib/webpacker/configuration.rb