Class: Webpacker::Configuration
- Inherits:
-
FileLoader
- Object
- FileLoader
- Webpacker::Configuration
- Defined in:
- lib/webpacker/configuration.rb
Instance Attribute Summary
Attributes inherited from FileLoader
Class Method Summary collapse
- .compile? ⇒ Boolean
- .data ⇒ Object
- .default_file_path ⇒ Object
- .defaults ⇒ Object
- .entry_path ⇒ Object
- .fetch(key) ⇒ Object
- .file_path(root: Rails.root) ⇒ Object
- .manifest_path ⇒ Object
- .output_path ⇒ Object
-
.output_path_or_url ⇒ Object
Uses the webpack dev server host if appropriate.
- .public_output_path ⇒ Object
- .public_path ⇒ Object
- .reset ⇒ Object
- .source ⇒ Object
- .source_path ⇒ Object
Methods inherited from FileLoader
Class Method Details
.compile? ⇒ Boolean
48 49 50 |
# File 'lib/webpacker/configuration.rb', line 48 def compile? fetch(:compile) end |
.data ⇒ Object
56 57 58 59 60 |
# 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 ⇒ Object
40 41 42 |
# File 'lib/webpacker/configuration.rb', line 40 def default_file_path file_path(root: Pathname.new(__dir__).join("../install")) end |
.defaults ⇒ Object
62 63 64 |
# File 'lib/webpacker/configuration.rb', line 62 def defaults @defaults ||= HashWithIndifferentAccess.new(YAML.load(default_file_path.read)[Webpacker.env]) end |
.entry_path ⇒ Object
12 13 14 |
# File 'lib/webpacker/configuration.rb', line 12 def entry_path source_path.join(fetch(:source_entry_path)) end |
.fetch(key) ⇒ Object
52 53 54 |
# File 'lib/webpacker/configuration.rb', line 52 def fetch(key) data.fetch(key, defaults[key]) end |
.file_path(root: Rails.root) ⇒ Object
36 37 38 |
# File 'lib/webpacker/configuration.rb', line 36 def file_path(root: Rails.root) root.join("config/webpacker.yml") end |
.manifest_path ⇒ Object
24 25 26 |
# File 'lib/webpacker/configuration.rb', line 24 def manifest_path output_path.join("manifest.json") end |
.output_path ⇒ Object
20 21 22 |
# File 'lib/webpacker/configuration.rb', line 20 def output_path public_path.join(public_output_path) end |
.output_path_or_url ⇒ Object
Uses the webpack dev server host if appropriate
67 68 69 70 71 72 73 74 75 |
# 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 ⇒ Object
16 17 18 |
# File 'lib/webpacker/configuration.rb', line 16 def public_output_path fetch(:public_output_path) end |
.public_path ⇒ Object
32 33 34 |
# File 'lib/webpacker/configuration.rb', line 32 def public_path Rails.root.join("public") end |
.reset ⇒ Object
7 8 9 10 |
# File 'lib/webpacker/configuration.rb', line 7 def reset @defaults = nil super end |
.source ⇒ Object
44 45 46 |
# File 'lib/webpacker/configuration.rb', line 44 def source fetch(:source_path) end |
.source_path ⇒ Object
28 29 30 |
# File 'lib/webpacker/configuration.rb', line 28 def source_path Rails.root.join(source) end |