lib/generators/react/install_generator.rb in react-rails-2.6.2 vs lib/generators/react/install_generator.rb in react-rails-2.7.0.rc.0

- old
+ new

@@ -14,10 +14,23 @@ class_option :skip_server_rendering, type: :boolean, default: false, desc: "Don't generate server_rendering.js or config/initializers/react_server_rendering.rb" + # For Shakapacker below version 7, we need to set relative path for source_entry_path + def modify_webpacker_yml + webpacker_yml_path = 'config/webpacker.yml' + if webpacker? && Pathname.new(webpacker_yml_path).exist? + gsub_file( + webpacker_yml_path, + "source_entry_path: /\n", + "source_entry_path: packs\n" + ) + reloaded_webpacker_config + end + end + # Make an empty `components/` directory in the right place: def create_directory components_dir = if webpacker? Pathname.new(javascript_dir).parent.to_s else @@ -116,9 +129,14 @@ if Webpacker.respond_to?(:config) Webpacker.config.source_entry_path # Webpacker >3 else Webpacker::Configuration.source_path.join(Webpacker::Configuration.entry_path) # Webpacker <3 end + end + + def reloaded_webpacker_config + Webpacker.instance.instance_variable_set(:@config, nil) + Webpacker.config end end end end