Skip to content

Commit 68f4baf

Browse files
justin808claude
andcommitted
Fix CI failure by not setting default generated_assets_dir with Shakapacker
The configuration was automatically setting generated_assets_dir to a default value that didn't match Shakapacker's public_output_path, causing validation errors in CI and example apps. Since Shakapacker manages its own public_output_path configuration, we should not set a default generated_assets_dir when using Shakapacker. This prevents path mismatches and allows proper Shakapacker configuration. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 37e54a1 commit 68f4baf

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

lib/react_on_rails/configuration.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,10 @@ def check_server_render_method_is_only_execjs
269269
def ensure_generated_assets_dir_present
270270
return if generated_assets_dir.present?
271271

272-
self.generated_assets_dir = DEFAULT_GENERATED_ASSETS_DIR
273-
Rails.logger.warn "ReactOnRails: Set generated_assets_dir to default: #{DEFAULT_GENERATED_ASSETS_DIR}"
272+
# When using Shakapacker, don't set a default generated_assets_dir since
273+
# Shakapacker manages its own public_output_path configuration
274+
# This prevents configuration mismatches between ReactOnRails and Shakapacker
275+
Rails.logger.warn "ReactOnRails: No generated_assets_dir specified, using Shakapacker public_output_path"
274276
end
275277

276278
def configure_generated_assets_dirs_deprecation

spec/react_on_rails/configuration_spec.rb

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,19 @@ module ReactOnRails
313313
expect(ReactOnRails.configuration.random_dom_id).to be(false)
314314
end
315315

316+
it "works without specifying generated_assets_dir when using Shakapacker" do
317+
allow(ReactOnRails::PackerUtils).to receive_message_chain("packer.config.public_output_path")
318+
.and_return(Pathname.new("/tmp/public/packs"))
319+
320+
expect do
321+
ReactOnRails.configure do |config|
322+
config.server_bundle_js_file = "server.js"
323+
end
324+
end.not_to raise_error
325+
326+
expect(ReactOnRails.configuration.generated_assets_dir).to be_blank
327+
end
328+
316329
it "calls raise_missing_components_subdirectory if auto_load_bundle = true & components_subdirectory is not set" do
317330
expect do
318331
ReactOnRails.configure do |config|

0 commit comments

Comments
 (0)