class Webpacker::Configuration
Attributes
installing[RW]
config_path[R]
env[R]
root_path[R]
Public Class Methods
new(root_path:, config_path:, env:)
click to toggle source
# File lib/webpacker/configuration.rb, line 12 def initialize(root_path:, config_path:, env:) @root_path = root_path @config_path = config_path @env = env end
Public Instance Methods
additional_paths()
click to toggle source
# File lib/webpacker/configuration.rb, line 34 def additional_paths fetch(:additional_paths) end
cache_manifest?()
click to toggle source
# File lib/webpacker/configuration.rb, line 62 def cache_manifest? fetch(:cache_manifest) end
cache_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 66 def cache_path root_path.join(fetch(:cache_path)) end
check_yarn_integrity=(value)
click to toggle source
# File lib/webpacker/configuration.rb, line 70 def check_yarn_integrity=(value) warn <<~EOS Webpacker::Configuration#check_yarn_integrity=(value) is obsolete. The integrity check has been removed from Webpacker (https://github.com/rails/webpacker/pull/2518) so changing this setting will have no effect. EOS end
compile?()
click to toggle source
# File lib/webpacker/configuration.rb, line 22 def compile? fetch(:compile) end
dev_server()
click to toggle source
# File lib/webpacker/configuration.rb, line 18 def dev_server fetch(:dev_server) end
ensure_consistent_versioning?()
click to toggle source
# File lib/webpacker/configuration.rb, line 26 def ensure_consistent_versioning? fetch(:ensure_consistent_versioning) end
fetch(key)
click to toggle source
# File lib/webpacker/configuration.rb, line 82 def fetch(key) data.fetch(key, defaults[key]) end
manifest_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 42 def manifest_path if data.has_key?(:manifest_path) root_path.join(fetch(:manifest_path)) else public_output_path.join("manifest.json") end end
public_manifest_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 50 def public_manifest_path manifest_path end
public_output_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 58 def public_output_path public_path.join(fetch(:public_output_path)) end
public_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 54 def public_path root_path.join(fetch(:public_root_path)) end
source_entry_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 38 def source_entry_path source_path.join(fetch(:source_entry_path)) end
source_path()
click to toggle source
# File lib/webpacker/configuration.rb, line 30 def source_path root_path.join(fetch(:source_path)) end
webpack_compile_output?()
click to toggle source
# File lib/webpacker/configuration.rb, line 78 def webpack_compile_output? fetch(:webpack_compile_output) end
Private Instance Methods
data()
click to toggle source
# File lib/webpacker/configuration.rb, line 87 def data @data ||= load end
defaults()
click to toggle source
# File lib/webpacker/configuration.rb, line 112 def defaults @defaults ||= begin path = File.expand_path("../../install/config/webpacker.yml", __FILE__) config = begin YAML.load_file(path, aliases: true) rescue ArgumentError YAML.load_file(path) end HashWithIndifferentAccess.new(config[env]) end end
load()
click to toggle source
# File lib/webpacker/configuration.rb, line 91 def load config = begin YAML.load_file(config_path.to_s, aliases: true) rescue ArgumentError YAML.load_file(config_path.to_s) end config[env].deep_symbolize_keys rescue Errno::ENOENT => e if self.class.installing {} else raise "Webpacker configuration file not found #{config_path}. " \ "Please run rails webpacker:install " \ "Error: #{e.message}" end 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