class ReactOnRails::Generators::AdaptForOlderShakapackerGenerator

Public Instance Methods

change_spelling_to_webpacker() click to toggle source
# File lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb, line 12
def change_spelling_to_webpacker
  puts "Change spelling to webpacker v7"
  files = %w[
    Procfile.dev
    Procfile.dev-static
    config/shakapacker.yml
    config/initializers/react_on_rails.rb
  ]
  files.each { |file| gsub_file(file, "shakapacker", "webpacker") }
end
modify_requiring_webpack_config_in_js() click to toggle source
# File lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb, line 29
def modify_requiring_webpack_config_in_js
  puts "Update commonWebpackConfig.js to follow the Shakapacker v6 interface"
  file = "config/webpack/commonWebpackConfig.js"
  gsub_file(file, "const baseClientWebpackConfig = generateWebpackConfig();\n\n", "")
  gsub_file(
    file,
    "const { generateWebpackConfig, merge } = require('shakapacker');",
    "const { webpackConfig: baseClientWebpackConfig, merge } = require('shakapacker');"
  )
end
rename_config_file() click to toggle source
# File lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb, line 23
def rename_config_file
  puts "Rename to config/webpacker.yml"
  puts "Renaming shakapacker.yml into webpacker.yml"
  FileUtils.mv("config/shakapacker.yml", "config/webpacker.yml")
end