Class: Shakapacker::Configuration
- Inherits:
-
Object
- Object
- Shakapacker::Configuration
- Defined in:
- lib/shakapacker/configuration.rb
Class Attribute Summary collapse
-
.installing ⇒ Object
Returns the value of attribute installing.
Instance Attribute Summary collapse
-
#config_path ⇒ Object
readonly
Returns the value of attribute config_path.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#root_path ⇒ Object
readonly
Returns the value of attribute root_path.
Instance Method Summary collapse
- #additional_paths ⇒ Object
- #cache_manifest? ⇒ Boolean
- #cache_path ⇒ Object
- #compile? ⇒ Boolean
- #compiler_strategy ⇒ Object
- #dev_server ⇒ Object
- #ensure_consistent_versioning? ⇒ Boolean
- #fetch(key) ⇒ Object
-
#initialize(root_path:, config_path:, env:) ⇒ Configuration
constructor
A new instance of Configuration.
- #manifest_path ⇒ Object
- #nested_entries? ⇒ Boolean
- #public_manifest_path ⇒ Object
- #public_output_path ⇒ Object
- #public_path ⇒ Object
- #shakapacker_precompile? ⇒ Boolean
- #source_entry_path ⇒ Object
- #source_path ⇒ Object
- #webpack_compile_output? ⇒ Boolean
- #webpacker_precompile? ⇒ Boolean
Constructor Details
#initialize(root_path:, config_path:, env:) ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 16 17 18 19 |
# File 'lib/shakapacker/configuration.rb', line 12 def initialize(root_path:, config_path:, env:) @root_path = root_path @env = env # For backward compatibility Shakapacker.set_shakapacker_env_variables_for_backward_compatibility @config_path = Pathname.new(ENV["SHAKAPACKER_CONFIG"] || config_path) end |
Class Attribute Details
.installing ⇒ Object
Returns the value of attribute installing.
7 8 9 |
# File 'lib/shakapacker/configuration.rb', line 7 def installing @installing end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
10 11 12 |
# File 'lib/shakapacker/configuration.rb', line 10 def config_path @config_path end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
10 11 12 |
# File 'lib/shakapacker/configuration.rb', line 10 def env @env end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
10 11 12 |
# File 'lib/shakapacker/configuration.rb', line 10 def root_path @root_path end |
Instance Method Details
#additional_paths ⇒ Object
61 62 63 |
# File 'lib/shakapacker/configuration.rb', line 61 def additional_paths fetch(:additional_paths) end |
#cache_manifest? ⇒ Boolean
89 90 91 |
# File 'lib/shakapacker/configuration.rb', line 89 def cache_manifest? fetch(:cache_manifest) end |
#cache_path ⇒ Object
93 94 95 |
# File 'lib/shakapacker/configuration.rb', line 93 def cache_path root_path.join(fetch(:cache_path)) end |
#compile? ⇒ Boolean
25 26 27 |
# File 'lib/shakapacker/configuration.rb', line 25 def compile? fetch(:compile) end |
#compiler_strategy ⇒ Object
101 102 103 |
# File 'lib/shakapacker/configuration.rb', line 101 def compiler_strategy fetch(:compiler_strategy) end |
#dev_server ⇒ Object
21 22 23 |
# File 'lib/shakapacker/configuration.rb', line 21 def dev_server fetch(:dev_server) end |
#ensure_consistent_versioning? ⇒ Boolean
33 34 35 |
# File 'lib/shakapacker/configuration.rb', line 33 def ensure_consistent_versioning? fetch(:ensure_consistent_versioning) end |
#fetch(key) ⇒ Object
105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/shakapacker/configuration.rb', line 105 def fetch(key) return data.fetch(key, defaults[key]) unless key == :webpacker_precompile # for backward compatibility Shakapacker.( Shakapacker.( "webpacker_precompile", "shakapacker_precompile" ) ) data.fetch(key, defaults[:shakapacker_precompile]) end |
#manifest_path ⇒ Object
69 70 71 72 73 74 75 |
# File 'lib/shakapacker/configuration.rb', line 69 def manifest_path if data.has_key?(:manifest_path) root_path.join(fetch(:manifest_path)) else public_output_path.join("manifest.json") end end |
#nested_entries? ⇒ Boolean
29 30 31 |
# File 'lib/shakapacker/configuration.rb', line 29 def nested_entries? fetch(:nested_entries) end |
#public_manifest_path ⇒ Object
77 78 79 |
# File 'lib/shakapacker/configuration.rb', line 77 def public_manifest_path manifest_path end |
#public_output_path ⇒ Object
85 86 87 |
# File 'lib/shakapacker/configuration.rb', line 85 def public_output_path public_path.join(fetch(:public_output_path)) end |
#public_path ⇒ Object
81 82 83 |
# File 'lib/shakapacker/configuration.rb', line 81 def public_path root_path.join(fetch(:public_root_path)) end |
#shakapacker_precompile? ⇒ Boolean
37 38 39 40 41 42 43 44 |
# File 'lib/shakapacker/configuration.rb', line 37 def shakapacker_precompile? # ENV of false takes precedence return false if %w(no false n f).include?(ENV["SHAKAPACKER_PRECOMPILE"]) return true if %w(yes true y t).include?(ENV["SHAKAPACKER_PRECOMPILE"]) return false unless config_path.exist? fetch(:shakapacker_precompile) end |
#source_entry_path ⇒ Object
65 66 67 |
# File 'lib/shakapacker/configuration.rb', line 65 def source_entry_path source_path.join(relative_path(fetch(:source_entry_path))) end |
#source_path ⇒ Object
57 58 59 |
# File 'lib/shakapacker/configuration.rb', line 57 def source_path root_path.join(fetch(:source_path)) end |
#webpack_compile_output? ⇒ Boolean
97 98 99 |
# File 'lib/shakapacker/configuration.rb', line 97 def webpack_compile_output? fetch(:webpack_compile_output) end |
#webpacker_precompile? ⇒ Boolean
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/shakapacker/configuration.rb', line 46 def webpacker_precompile? Shakapacker.( Shakapacker.( "webpacker_precompile?", "shakapacker_precompile?" ) ) shakapacker_precompile? end |