class Webpacker::Configuration

Public Class Methods

new(webpacker) click to toggle source
# File lib/webpacker/configuration.rb, line 4
def initialize(webpacker)
  @webpacker = webpacker
end

Public Instance Methods

cache_manifest?() click to toggle source
# File lib/webpacker/configuration.rb, line 48
def cache_manifest?
  fetch(:cache_manifest)
end
cache_path() click to toggle source
# File lib/webpacker/configuration.rb, line 52
def cache_path
  root_path.join(fetch(:cache_path))
end
compile?() click to toggle source
# File lib/webpacker/configuration.rb, line 16
def compile?
  fetch(:compile)
end
dev_server() click to toggle source
# File lib/webpacker/configuration.rb, line 12
def dev_server
  fetch(:dev_server)
end
extensions() click to toggle source
# File lib/webpacker/configuration.rb, line 56
def extensions
  fetch(:extensions)
end
public_manifest_path() click to toggle source
# File lib/webpacker/configuration.rb, line 44
def public_manifest_path
  public_output_path.join("manifest.json")
end
public_output_path() click to toggle source
# File lib/webpacker/configuration.rb, line 40
def public_output_path
  public_path.join(fetch(:public_output_path))
end
public_path() click to toggle source
# File lib/webpacker/configuration.rb, line 36
def public_path
  root_path.join("public")
end
refresh() click to toggle source
# File lib/webpacker/configuration.rb, line 8
def refresh
  @data = load
end
resolved_paths() click to toggle source
# File lib/webpacker/configuration.rb, line 24
def resolved_paths
  fetch(:resolved_paths)
end
resolved_paths_globbed() click to toggle source
# File lib/webpacker/configuration.rb, line 28
def resolved_paths_globbed
  resolved_paths.map { |p| "#{p}/**/*" }
end
source_entry_path() click to toggle source
# File lib/webpacker/configuration.rb, line 32
def source_entry_path
  source_path.join(fetch(:source_entry_path))
end
source_path() click to toggle source
# File lib/webpacker/configuration.rb, line 20
def source_path
  root_path.join(fetch(:source_path))
end

Private Instance Methods

data() click to toggle source
# File lib/webpacker/configuration.rb, line 65
def data
  @data ||= load
end
defaults() click to toggle source
# File lib/webpacker/configuration.rb, line 83
def defaults
  @defaults ||= \
    HashWithIndifferentAccess.new(YAML.load_file(File.expand_path("../../install/config/webpacker.yml", __FILE__))[env])
end
fetch(key) click to toggle source
# File lib/webpacker/configuration.rb, line 61
def fetch(key)
  data.fetch(key, defaults[key])
end
load() click to toggle source
# File lib/webpacker/configuration.rb, line 69
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