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
- #asset_host ⇒ Object
- #assets_bundler ⇒ Object
-
#bundler ⇒ Object
Deprecated: Use assets_bundler instead.
- #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.
- #integrity ⇒ Object
- #javascript_transpiler ⇒ Object
- #manifest_path ⇒ Object
- #nested_entries? ⇒ Boolean
- #private_output_path ⇒ Object
- #public_manifest_path ⇒ Object
- #public_output_path ⇒ Object
- #public_path ⇒ Object
- #rspack? ⇒ Boolean
- #shakapacker_precompile? ⇒ Boolean
- #source_entry_path ⇒ Object
- #source_path ⇒ Object
- #webpack? ⇒ Boolean
- #webpack_compile_output? ⇒ Boolean
-
#webpack_loader ⇒ Object
Deprecated: Use javascript_transpiler instead.
Constructor Details
#initialize(root_path:, config_path:, env:) ⇒ Configuration
Returns a new instance of Configuration.
13 14 15 16 17 |
# File 'lib/shakapacker/configuration.rb', line 13 def initialize(root_path:, config_path:, env:) @root_path = root_path @env = env @config_path = config_path end |
Class Attribute Details
.installing ⇒ Object
Returns the value of attribute installing.
8 9 10 |
# File 'lib/shakapacker/configuration.rb', line 8 def installing @installing end |
Instance Attribute Details
#config_path ⇒ Object (readonly)
Returns the value of attribute config_path.
11 12 13 |
# File 'lib/shakapacker/configuration.rb', line 11 def config_path @config_path end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
11 12 13 |
# File 'lib/shakapacker/configuration.rb', line 11 def env @env end |
#root_path ⇒ Object (readonly)
Returns the value of attribute root_path.
11 12 13 |
# File 'lib/shakapacker/configuration.rb', line 11 def root_path @root_path end |
Instance Method Details
#additional_paths ⇒ Object
48 49 50 |
# File 'lib/shakapacker/configuration.rb', line 48 def additional_paths fetch(:additional_paths) end |
#asset_host ⇒ Object
204 205 206 207 208 209 |
# File 'lib/shakapacker/configuration.rb', line 204 def asset_host ENV.fetch( "SHAKAPACKER_ASSET_HOST", fetch(:asset_host) || ActionController::Base.helpers.compute_asset_host ) end |
#assets_bundler ⇒ Object
99 100 101 102 103 104 105 |
# File 'lib/shakapacker/configuration.rb', line 99 def assets_bundler # Show deprecation warning if using old 'bundler' key if data.has_key?(:bundler) && !data.has_key?(:assets_bundler) $stderr.puts "⚠️ DEPRECATION WARNING: The 'bundler' configuration option is deprecated. Please use 'assets_bundler' instead to avoid confusion with Ruby's Bundler gem manager." end ENV["SHAKAPACKER_ASSETS_BUNDLER"] || fetch(:assets_bundler) || fetch(:bundler) || "webpack" end |
#bundler ⇒ Object
Deprecated: Use assets_bundler instead
108 109 110 |
# File 'lib/shakapacker/configuration.rb', line 108 def bundler assets_bundler end |
#cache_manifest? ⇒ Boolean
83 84 85 |
# File 'lib/shakapacker/configuration.rb', line 83 def cache_manifest? fetch(:cache_manifest) end |
#cache_path ⇒ Object
87 88 89 |
# File 'lib/shakapacker/configuration.rb', line 87 def cache_path root_path.join(fetch(:cache_path)) end |
#compile? ⇒ Boolean
23 24 25 |
# File 'lib/shakapacker/configuration.rb', line 23 def compile? fetch(:compile) end |
#compiler_strategy ⇒ Object
95 96 97 |
# File 'lib/shakapacker/configuration.rb', line 95 def compiler_strategy fetch(:compiler_strategy) end |
#dev_server ⇒ Object
19 20 21 |
# File 'lib/shakapacker/configuration.rb', line 19 def dev_server fetch(:dev_server) end |
#ensure_consistent_versioning? ⇒ Boolean
31 32 33 |
# File 'lib/shakapacker/configuration.rb', line 31 def ensure_consistent_versioning? fetch(:ensure_consistent_versioning) end |
#fetch(key) ⇒ Object
200 201 202 |
# File 'lib/shakapacker/configuration.rb', line 200 def fetch(key) data.fetch(key, defaults[key]) end |
#integrity ⇒ Object
211 212 213 |
# File 'lib/shakapacker/configuration.rb', line 211 def integrity fetch(:integrity) end |
#javascript_transpiler ⇒ Object
120 121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/shakapacker/configuration.rb', line 120 def javascript_transpiler # Show deprecation warning if using old 'webpack_loader' key if data.has_key?(:webpack_loader) && !data.has_key?(:javascript_transpiler) $stderr.puts "⚠️ DEPRECATION WARNING: The 'webpack_loader' configuration option is deprecated. Please use 'javascript_transpiler' instead as it better reflects its purpose of configuring JavaScript transpilation regardless of the bundler used." end # Use explicit config if set, otherwise default based on bundler transpiler = fetch(:javascript_transpiler) || fetch(:webpack_loader) || default_javascript_transpiler # Validate transpiler configuration validate_transpiler_configuration(transpiler) unless self.class.installing transpiler end |
#manifest_path ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/shakapacker/configuration.rb', line 56 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
27 28 29 |
# File 'lib/shakapacker/configuration.rb', line 27 def nested_entries? fetch(:nested_entries) end |
#private_output_path ⇒ Object
72 73 74 75 76 77 |
# File 'lib/shakapacker/configuration.rb', line 72 def private_output_path private_path = fetch(:private_output_path) return nil unless private_path validate_output_paths! root_path.join(private_path) end |
#public_manifest_path ⇒ Object
64 65 66 |
# File 'lib/shakapacker/configuration.rb', line 64 def public_manifest_path manifest_path end |
#public_output_path ⇒ Object
79 80 81 |
# File 'lib/shakapacker/configuration.rb', line 79 def public_output_path public_path.join(fetch(:public_output_path)) end |
#public_path ⇒ Object
68 69 70 |
# File 'lib/shakapacker/configuration.rb', line 68 def public_path root_path.join(fetch(:public_root_path)) end |
#rspack? ⇒ Boolean
112 113 114 |
# File 'lib/shakapacker/configuration.rb', line 112 def rspack? assets_bundler == "rspack" end |
#shakapacker_precompile? ⇒ Boolean
35 36 37 38 39 40 41 42 |
# File 'lib/shakapacker/configuration.rb', line 35 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
52 53 54 |
# File 'lib/shakapacker/configuration.rb', line 52 def source_entry_path source_path.join(relative_path(fetch(:source_entry_path))) end |
#source_path ⇒ Object
44 45 46 |
# File 'lib/shakapacker/configuration.rb', line 44 def source_path root_path.join(fetch(:source_path)) end |
#webpack? ⇒ Boolean
116 117 118 |
# File 'lib/shakapacker/configuration.rb', line 116 def webpack? assets_bundler == "webpack" end |
#webpack_compile_output? ⇒ Boolean
91 92 93 |
# File 'lib/shakapacker/configuration.rb', line 91 def webpack_compile_output? fetch(:webpack_compile_output) end |
#webpack_loader ⇒ Object
Deprecated: Use javascript_transpiler instead
136 137 138 |
# File 'lib/shakapacker/configuration.rb', line 136 def webpack_loader javascript_transpiler end |