Skip to content

Commit 369f5a7

Browse files
Enhance server bundle path resolution logic
- Updated the logic for determining server bundle paths to include a fallback mechanism that checks for the existence of paths based on the `enforce_private_server_bundles` configuration. - This change ensures that if the enforcement is not active, the system will attempt to return the first valid path from a list of candidate paths, improving robustness in asset management. This update aligns with recent changes to clarify the handling of server bundles and enhances the overall functionality of the asset resolution process.
1 parent ffa58ac commit 369f5a7

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

lib/react_on_rails/utils.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,15 @@ def self.bundle_js_file_path(bundle_name)
121121

122122
# For server bundles with server_bundle_output_path configured, use that
123123
if is_server_bundle && config.server_bundle_output_path.present?
124-
return File.expand_path(File.join(root_path, config.server_bundle_output_path, bundle_name))
124+
candidate_paths = [File.expand_path(File.join(root_path, config.server_bundle_output_path, bundle_name))]
125+
unless config.enforce_private_server_bundles
126+
candidate_paths << File.expand_path(File.join(root_path, config.server_bundle_output_path, bundle_name))
127+
end
128+
129+
candidate_paths.each do |path|
130+
return path if File.exist?(path)
131+
end
132+
return candidate_paths.first
125133
end
126134

127135
# For client bundles and server bundles without special config, use packer's public path

0 commit comments

Comments
 (0)