- 
          
 - 
                Notifications
    
You must be signed in to change notification settings  - Fork 100
 
Description
Background
In PR #706 (Add timing logs for webpack and rspack builds), auto-configuration logic was added to spec/dummy/bin/shakapacker and spec/dummy/bin/shakapacker-dev-server to automatically copy shakapacker-webpack.yml to shakapacker.yml if it doesn't exist.
While this improves the developer experience for the test app, there are some considerations:
Issues
- Scope creep: This feature is outside the stated scope of the timing logs PR
 - Emoji usage: Uses emojis (📦, 💡) but 
CLAUDE.mdsays to avoid emojis unless requested - Code duplication: The auto-setup logic is duplicated between both bin scripts
 - Not git-ignored: The generated 
config/shakapacker.ymlisn't git-ignored, which could lead to unwanted commits 
Recommendations
Option 1: Extract to Shared Helper
Create a shared helper method in spec/dummy/config/application.rb or a new lib/ file:
# spec/dummy/lib/shakapacker_auto_setup.rb
module ShakapackerAutoSetup
  def self.ensure_config!(app_root)
    config_dir = File.join(app_root, "config")
    shakapacker_config = File.join(config_dir, "shakapacker.yml")
    webpack_config = File.join(config_dir, "shakapacker-webpack.yml")
    return if File.exist?(shakapacker_config)
    return unless File.exist?(webpack_config)
    require "fileutils"
    FileUtils.cp(webpack_config, shakapacker_config)
    
    $stderr.puts "Auto-configured with webpack (copied shakapacker-webpack.yml -> shakapacker.yml)"
    $stderr.puts "To switch bundlers, use: bin/test-bundler [webpack|rspack]"
  end
endThen both bin scripts can call: ShakapackerAutoSetup.ensure_config!(APP_ROOT)
Option 2: Use .gitignore
Add to spec/dummy/.gitignore:
config/shakapacker.yml
This prevents accidental commits of the auto-generated config.
Option 3: Remove Auto-Configuration
If we want to keep the test app strictly manual, remove the auto-configuration and rely on the README instructions to run bin/test-bundler first.
Priority
Low - This is a nice-to-have improvement for code quality and maintainability, not a critical issue.
Related
- PR Add timing logs for webpack and rspack builds #706
 spec/dummy/bin/shakapacker(lines 7-20)spec/dummy/bin/shakapacker-dev-server(lines 8-21)