diff --git a/lib/react_on_rails/configuration.rb b/lib/react_on_rails/configuration.rb index 795340bb30..609e9adc5a 100644 --- a/lib/react_on_rails/configuration.rb +++ b/lib/react_on_rails/configuration.rb @@ -215,7 +215,7 @@ def configure_generated_assets_dirs_deprecation packer_public_output_path = ReactOnRails::PackerUtils.packer_public_output_path # rubocop:disable Layout/LineLength Rails.logger.warn "Error configuring config/initializers/react_on_rails. Define neither the generated_assets_dirs nor " \ - "the generated_assets_dir when using Shakapacker. This is defined by " \ + "the generated_assets_dir when using #{ReactOnRails::PackerUtils.packer_type.upcase_first}. This is defined by " \ "public_output_path specified in #{ReactOnRails::PackerUtils.packer_type}.yml = #{packer_public_output_path}." # rubocop:enable Layout/LineLength return @@ -257,18 +257,10 @@ def raise_missing_components_subdirectory raise ReactOnRails::Error, msg end - def shakapacker_precompile? - Shakapacker.config.shakapacker_precompile? - end - - def shakapacker_clean_task - "shakapacker:clean" - end - def compile_command_conflict_message <<~MSG - React on Rails and Shakapacker error in configuration! + React on Rails and #{ReactOnRails::PackerUtils.packer_type.upcase_first} error in configuration! In order to use config/react_on_rails.rb config.build_production_command, you must edit config/#{ReactOnRails::PackerUtils.packer_type}.yml to include this value in the default configuration: '#{ReactOnRails::PackerUtils.packer_type}_precompile: false' diff --git a/lib/react_on_rails/packer_utils.rb b/lib/react_on_rails/packer_utils.rb index 5569b4a718..6566305d3f 100644 --- a/lib/react_on_rails/packer_utils.rb +++ b/lib/react_on_rails/packer_utils.rb @@ -28,7 +28,7 @@ def self.packer_type nil end - def self.adapter + def self.packer return nil unless using_packer? if using_shakapacker? @@ -42,7 +42,7 @@ def self.adapter def self.dev_server_running? return false unless using_packer? - adapter.dev_server.running? + packer.dev_server.running? end def self.shakapacker_version @@ -68,7 +68,7 @@ def self.shakapacker_version_requirement_met?(required_version) # the hashed server bundle if using the same bundle for the client. # Otherwise returns a file path. def self.bundle_js_uri_from_packer(bundle_name) - hashed_bundle_name = adapter.manifest.lookup!(bundle_name) + hashed_bundle_name = packer.manifest.lookup!(bundle_name) # Support for hashing the server-bundle and having that built # the webpack-dev-server is provided by the config value @@ -76,9 +76,9 @@ def self.bundle_js_uri_from_packer(bundle_name) # would mean that the bundle is created by the webpack-dev-server is_server_bundle = bundle_name == ReactOnRails.configuration.server_bundle_js_file - if adapter.dev_server.running? && (!is_server_bundle || + if packer.dev_server.running? && (!is_server_bundle || ReactOnRails.configuration.same_bundle_for_client_and_server) - "#{adapter.dev_server.protocol}://#{adapter.dev_server.host_with_port}#{hashed_bundle_name}" + "#{packer.dev_server.protocol}://#{packer.dev_server.host_with_port}#{hashed_bundle_name}" else File.expand_path(File.join("public", hashed_bundle_name)).to_s end @@ -92,31 +92,31 @@ def self.precompile? end def self.packer_source_path - adapter.config.source_path + packer.config.source_path end def self.packer_source_entry_path - adapter.config.source_entry_path + packer.config.source_entry_path end def self.nested_entries? - adapter.config.nested_entries? + packer.config.nested_entries? end def self.packer_public_output_path - adapter.config.public_output_path.to_s + packer.config.public_output_path.to_s end def self.manifest_exists? - adapter.config.public_manifest_path.exist? + packer.config.public_manifest_path.exist? end def self.packer_source_path_explicit? - adapter.config.send(:data)[:source_path].present? + packer.config.send(:data)[:source_path].present? end def self.check_manifest_not_cached - return unless using_packer? && adapter.config.cache_manifest? + return unless using_packer? && packer.config.cache_manifest? msg = <<-MSG.strip_heredoc ERROR: you have enabled cache_manifest in the #{Rails.env} env when using the diff --git a/lib/react_on_rails/utils.rb b/lib/react_on_rails/utils.rb index c92067b889..8c5bb0d638 100644 --- a/lib/react_on_rails/utils.rb +++ b/lib/react_on_rails/utils.rb @@ -82,7 +82,7 @@ def self.server_bundle_js_file_path @server_bundle_path = if ReactOnRails::PackerUtils.using_packer? begin bundle_js_file_path(bundle_name) - rescue ReactOnRails::PackerUtils.adapter::Manifest::MissingEntryError + rescue ReactOnRails::PackerUtils.packer::Manifest::MissingEntryError File.expand_path( File.join(ReactOnRails::PackerUtils.packer_public_output_path, bundle_name)