class Webpacker::Configuration

Public Class Methods

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

Public Instance Methods

cache_manifest?() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 40
def cache_manifest?
  fetch(:cache_manifest)
end
cache_path() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 44
def cache_path
  root_path.join(fetch(:cache_path))
end
compile?() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 16
def compile?
  fetch(:compile)
end
dev_server() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 12
def dev_server
  fetch(:dev_server)
end
public_manifest_path() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 36
def public_manifest_path
  public_output_path.join("manifest.json")
end
public_output_path() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 32
def public_output_path
  public_path.join(fetch(:public_output_path))
end
public_path() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 28
def public_path
  root_path.join("public")
end
refresh() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 8
def refresh
  @data = load_for_refresh
end
source_entry_path() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 24
def source_entry_path
  source_path.join(fetch(:source_entry_path))
end
source_path() click to toggle source
# File lib/webpacker-for-component/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-for-component/configuration.rb, line 53
def data
  @data ||= load
end
defaults() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 84
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-for-component/configuration.rb, line 49
def fetch(key)
  data.fetch(key, defaults[key])
end
load() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 57
def load
  YAML.load(root_path.join("config/webpacker.yml").read)[env].deep_symbolize_keys

rescue Errno::ENOENT => e
  raise "Webpacker configuration file not found #{root_path.join("config/webpacker.yml")}. " \
    "Please run rails webpacker:install " \
    "Error: #{e.message}"

  rescue Psych::SyntaxError => e
    raise "YAML syntax error occurred while parsing #{root_path.join("config/webpacker.yml")}. " \
      "Please note that YAML must be consistently indented using spaces. Tabs are not allowed. " \
      "Error: #{e.message}"
      end
load_for_refresh() click to toggle source
# File lib/webpacker-for-component/configuration.rb, line 71
def load_for_refresh
  YAML.load(root_path.join("components/angular/config/webpacker.yml").read)[env].deep_symbolize_keys
rescue Errno::ENOENT => e
  raise "Webpacker configuration file not found #{root_path.join("components/angular/config/webpacker.yml")}. " \
    "Please run rails webpacker:install " \
    "Error: #{e.message}"

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