Skip to content

Commit 4a92e0e

Browse files
committed
Use resolved webpack config path in doctor checker
1 parent 8da3444 commit 4a92e0e

2 files changed

Lines changed: 33 additions & 1 deletion

File tree

react_on_rails/lib/react_on_rails/system_checker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,7 @@ def check_react_on_rails_initializer
295295

296296
# Webpack configuration validation
297297
def check_webpack_configuration
298-
config_path = detect_bundler_config_path
298+
config_path = resolved_webpack_config_path
299299
if config_path
300300
add_success("✅ Bundler configuration exists (#{config_path})")
301301
check_webpack_config_content(config_path)

react_on_rails/spec/lib/react_on_rails/system_checker_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,38 @@
559559
end
560560
end
561561

562+
describe "#check_webpack_configuration" do
563+
context "when webpack config is resolved from a custom shakapacker location" do
564+
before do
565+
allow(checker).to receive(:resolved_webpack_config_path).and_return("config/custom/webpack.config.ts")
566+
allow(checker).to receive(:check_webpack_config_content)
567+
allow(checker).to receive(:suggest_webpack_inspection)
568+
end
569+
570+
it "reports success instead of an error" do
571+
checker.check_webpack_configuration
572+
573+
expect(checker.messages.any? do |msg|
574+
msg[:type] == :success && msg[:content].include?("config/custom/webpack.config.ts")
575+
end).to be true
576+
expect(checker.errors?).to be false
577+
end
578+
end
579+
580+
context "when no webpack config can be resolved" do
581+
before do
582+
allow(checker).to receive(:resolved_webpack_config_path).and_return(nil)
583+
end
584+
585+
it "reports an error" do
586+
checker.check_webpack_configuration
587+
588+
expect(checker.errors?).to be true
589+
expect(checker.messages.last[:content]).to include("Bundler configuration not found")
590+
end
591+
end
592+
end
593+
562594
describe "#check_react_dependencies" do
563595
let(:base_package_json) do
564596
{

0 commit comments

Comments
 (0)