@@ -11,6 +11,8 @@ module ReactOnRails
1111 class SystemChecker
1212 attr_reader :messages
1313
14+ SUPPORTED_ASSETS_BUNDLERS = %w[ webpack rspack ] . freeze
15+
1416 def initialize
1517 @messages = [ ]
1618 end
@@ -134,7 +136,8 @@ def check_shakapacker_configuration
134136 • bin/shakapacker
135137 • bin/shakapacker-dev-server
136138 • config/shakapacker.yml
137- • config/{webpack,rspack}/{webpack,rspack}.config.{js,ts}
139+ • config/webpack/webpack.config.{js,ts}
140+ • config/rspack/rspack.config.{js,ts}
138141
139142 Run: bundle exec rails shakapacker:install
140143 MSG
@@ -325,9 +328,9 @@ def detect_bundler_config_path
325328 end
326329
327330 add_warning (
328- "⚠️ Found both webpack and rspack configs. Could not determine active bundler; defaulting to rspack ."
331+ "⚠️ Found both webpack and rspack configs. Could not determine active bundler; defaulting to webpack ."
329332 )
330- paths_by_bundler [ "rspack " ] . first || paths_by_bundler [ "webpack " ] . first
333+ paths_by_bundler [ "webpack " ] . first || paths_by_bundler [ "rspack " ] . first
331334 end
332335
333336 def suggest_webpack_inspection ( config_path )
@@ -519,16 +522,27 @@ def existing_bundler_config_paths(bundler)
519522 end
520523
521524 def configured_assets_bundler
522- shakapacker_config_path = "config/shakapacker.yml"
523- return nil unless File . exist? ( shakapacker_config_path )
525+ config = parsed_shakapacker_config
526+ return nil unless config
524527
525- config_content = File . read ( shakapacker_config_path )
526- match = config_content . match ( /^\s *assets_bundler:\s *["']?(webpack|rspack)["']?\s *$/ )
527- match &.captures &.first
528- rescue StandardError
528+ rails_env = ENV [ "RAILS_ENV" ] || ENV [ "RACK_ENV" ] || "development"
529+ bundler_from_shakapacker_section ( config , rails_env ) || bundler_from_shakapacker_section ( config , "default" )
530+ rescue StandardError , ScriptError
529531 nil
530532 end
531533
534+ def bundler_from_shakapacker_section ( config , section_name )
535+ section = config [ section_name ] || config [ section_name . to_sym ]
536+ return nil unless section . is_a? ( Hash )
537+
538+ normalize_assets_bundler ( section [ "assets_bundler" ] || section [ :assets_bundler ] )
539+ end
540+
541+ def normalize_assets_bundler ( value )
542+ normalized = value . to_s . strip . downcase
543+ SUPPORTED_ASSETS_BUNDLERS . include? ( normalized ) ? normalized : nil
544+ end
545+
532546 def required_react_dependencies
533547 deps = {
534548 "react" => "React library" ,
0 commit comments