Class: ReactOnRails::Generators::AdaptForOlderShakapackerGenerator
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- ReactOnRails::Generators::AdaptForOlderShakapackerGenerator
show all
- Includes:
- GeneratorHelper
- Defined in:
- lib/generators/react_on_rails/adapt_for_older_shakapacker_generator.rb
Instance Method Summary
collapse
#add_documentation_reference, #copy_file_and_missing_parent_directories, #dest_dir_exists?, #dest_file_exists?, #empty_directory_with_keep_file, #keep_file, #setup_file_error, #symlink_dest_file_to_dest_file
Instance Method Details
#change_spelling_to_webpacker ⇒ Object
12
13
14
15
16
17
18
19
20
21
|
# 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 ⇒ Object
29
30
31
32
33
34
35
36
37
38
|
# 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 ⇒ Object
23
24
25
26
27
|
# 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
|