class Webpacker::Configuration

Public Class Methods

compile?() click to toggle source
# File lib/webpacker/configuration.rb, line 48
def compile?
  fetch(:compile)
end
data() click to toggle source
# File lib/webpacker/configuration.rb, line 56
def data
  load_instance if Webpacker.env.development?
  raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Configuration.load_data must be called first") unless instance
  instance.data
end
default_file_path() click to toggle source
# File lib/webpacker/configuration.rb, line 40
def default_file_path
  file_path(root: Pathname.new(__dir__).join("../install"))
end
defaults() click to toggle source
# File lib/webpacker/configuration.rb, line 62
def defaults
  @defaults ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)[Webpacker.env])
end
entry_path() click to toggle source
# File lib/webpacker/configuration.rb, line 12
def entry_path
  source_path.join(fetch(:source_entry_path))
end
fetch(key) click to toggle source
# File lib/webpacker/configuration.rb, line 52
def fetch(key)
  data.fetch(key, defaults[key])
end
file_path(root: Rails.root) click to toggle source
# File lib/webpacker/configuration.rb, line 36
def file_path(root: Rails.root)
  root.join("config/webpacker.yml")
end
manifest_path() click to toggle source
# File lib/webpacker/configuration.rb, line 24
def manifest_path
  output_path.join("manifest.json")
end
output_path() click to toggle source
# File lib/webpacker/configuration.rb, line 20
def output_path
  public_path.join(public_output_path)
end
output_path_or_url() click to toggle source

Uses the webpack dev server host if appropriate

# File lib/webpacker/configuration.rb, line 67
def output_path_or_url
  if Webpacker::DevServer.dev_server?
    Webpacker::DevServer.base_url
  else
    # Ensure we start with a slash so that the asset helpers don't prepend the default asset
    # pipeline locations.
    public_output_path.starts_with?("/") ? public_output_path : "/#{public_output_path}"
  end
end
public_output_path() click to toggle source
# File lib/webpacker/configuration.rb, line 16
def public_output_path
  fetch(:public_output_path)
end
public_path() click to toggle source
# File lib/webpacker/configuration.rb, line 32
def public_path
  Rails.root.join("public")
end
reset() click to toggle source
Calls superclass method Webpacker::FileLoader::reset
# File lib/webpacker/configuration.rb, line 7
def reset
  @defaults = nil
  super
end
source() click to toggle source
# File lib/webpacker/configuration.rb, line 44
def source
  fetch(:source_path)
end
source_path() click to toggle source
# File lib/webpacker/configuration.rb, line 28
def source_path
  Rails.root.join(source)
end

Private Instance Methods

load_data() click to toggle source
# File lib/webpacker/configuration.rb, line 79
def load_data
  return Webpacker::Configuration.defaults unless File.exist?(@path)
  HashWithIndifferentAccess.new(YAML.load(File.read(@path))[Webpacker.env])
end