Problem
When switching from webpack to rspack (re-running rails g react_on_rails:install --rspack on an existing webpack project), the old config/webpack/ directory and all its config files are left behind. The generator creates the new config/rspack/ configs but never cleans up the old ones.
Note: On a fresh install with --rspack, this does NOT happen — SHAKAPACKER_ASSETS_BUNDLER=rspack correctly tells Shakapacker to create config/rspack/ from the start. The stale files only appear when:
- A project was originally set up with webpack (has
config/webpack/)
- The user re-runs the generator with
--rspack to switch bundlers
Reproduction
# 1. Create app and install with webpack
rails new /tmp/ror_switch_test --minimal --skip-git --skip-bundle --skip-test --skip-javascript
cd /tmp/ror_switch_test
# Add react_on_rails and shakapacker to Gemfile
bundle install
git init && git add -A && git commit -m "init"
bundle exec rails g react_on_rails:install --ignore-warnings
git add -A && git commit -m "After webpack install"
# 2. Switch to rspack
bundle exec rails g react_on_rails:install --rspack --ignore-warnings
# 3. Observe stale files
ls config/webpack/ # Still has all 8 files!
ls config/rspack/ # Has the new configs
Result
Both directories exist with duplicate config files:
config/webpack/ (8 files — stale, unused)
config/rspack/ (8 files — active)
shakapacker.yml correctly points to rspack, so config/webpack/ is dead weight.
Affected Code
lib/generators/react_on_rails/base_generator.rb — copy_webpack_config creates new files via destination_config_path but doesn't remove old ones
- No cleanup logic exists anywhere in the generator flow
Expected Behavior
When --rspack is used on a project that has config/webpack/:
- Remove
config/webpack/ if it only contains stock configs
- If custom configs are detected, warn the user instead of silently leaving them
Context
Found during review of PR #2417. Related to #2410.
Problem
When switching from webpack to rspack (re-running
rails g react_on_rails:install --rspackon an existing webpack project), the oldconfig/webpack/directory and all its config files are left behind. The generator creates the newconfig/rspack/configs but never cleans up the old ones.Note: On a fresh install with
--rspack, this does NOT happen —SHAKAPACKER_ASSETS_BUNDLER=rspackcorrectly tells Shakapacker to createconfig/rspack/from the start. The stale files only appear when:config/webpack/)--rspackto switch bundlersReproduction
Result
Both directories exist with duplicate config files:
shakapacker.ymlcorrectly points to rspack, soconfig/webpack/is dead weight.Affected Code
lib/generators/react_on_rails/base_generator.rb—copy_webpack_configcreates new files viadestination_config_pathbut doesn't remove old onesExpected Behavior
When
--rspackis used on a project that hasconfig/webpack/:config/webpack/if it only contains stock configsContext
Found during review of PR #2417. Related to #2410.