Sha256: c17f892984d5e3b627f4f4ffdfbabb5a642057130e88098c2cde46f3189d9c11

Contents?: true

Size: 1.33 KB

Versions: 10

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

require "rails/generators"
require_relative "generator_helper"

module ReactOnRails
  module Generators
    class AdaptForOlderShakapackerGenerator < Rails::Generators::Base
      include GeneratorHelper
      Rails::Generators.hide_namespace(namespace)

      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

      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

      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
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
react_on_rails-14.1.1 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.1.0 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.1.0.rc.0 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-15.0.0.alpha.1 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.0.5 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.0.4 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.0.3 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.0.2 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-14.0.0 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
react_on_rails-13.4.0 lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb