Skip to content

Commit b1231f0

Browse files
elstgavjustin808
authored andcommitted
Fix Utils.bundle_js_file_path for manifest.json in webpacker projects (#1012)
* Fix Utils.bundle_js_file_path for manifest.json in webpacker projects Utils.bundle_js_file_path was incorrectly returning `'manifest.json'` instead of, say, `'/path/to/rails/public/packs/manifest.json'` Fixes #1011 * Make issue link explicit
1 parent 8f55608 commit b1231f0

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Changes since last non-beta release.
1010

1111
### [10.0.3] - 2018-1-8
1212
#### Fixed
13+
- Fixed `Utils.bundle_js_file_path` generating the incorrect path for `manifest.json` in webpacker projects: [Issue #1011](https://github.com/shakacode/react_on_rails/issues/1011) by [elstgav](https://github.com/elstgav)
1314
- Use redux component in generated redux Hello World example: [PR 1006](https://github.com/shakacode/react_on_rails/pull/1006) by [lewaabahmad](https://github.com/lewaabahmad).
1415

1516
### [10.0.2] - 2017-11-10

lib/react_on_rails/utils.rb

+1-2
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,7 @@ def self.server_bundle_js_file_path
8585
end
8686

8787
def self.bundle_js_file_path(bundle_name)
88-
if using_webpacker?
89-
return bundle_name if bundle_name == "manifest.json"
88+
if using_webpacker? && bundle_name != "manifest.json"
9089
bundle_js_file_path_from_webpacker(bundle_name)
9190
else
9291
# Default to the non-hashed name in the specified output directory, which, for legacy

spec/react_on_rails/utils_spec.rb

+18-5
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,33 @@ module ReactOnRails
1414
Utils.bundle_js_file_path("webpack-bundle.js")
1515
end
1616

17-
context "With Webpacker enabled and file in manifest", :webpacker do
17+
context "With Webpacker enabled", :webpacker do
1818
before do
1919
allow(Rails).to receive(:root).and_return(Pathname.new("."))
2020
allow(Webpacker).to receive_message_chain("dev_server.running?")
2121
.and_return(false)
2222
allow(Webpacker).to receive_message_chain("config.public_output_path")
2323
.and_return("/webpack/development")
24-
allow(Webpacker).to receive_message_chain("manifest.lookup")
25-
.with("webpack-bundle.js")
26-
.and_return("/webpack/development/webpack-bundle-0123456789abcdef.js")
2724
allow(Utils).to receive(:using_webpacker?).and_return(true)
2825
end
2926

30-
it { expect(subject).to eq("public/webpack/development/webpack-bundle-0123456789abcdef.js") }
27+
context "and file in manifest", :webpacker do
28+
before do
29+
allow(Webpacker).to receive_message_chain("manifest.lookup")
30+
.with("webpack-bundle.js")
31+
.and_return("/webpack/development/webpack-bundle-0123456789abcdef.js")
32+
end
33+
34+
it { expect(subject).to eq("public/webpack/development/webpack-bundle-0123456789abcdef.js") }
35+
end
36+
37+
context "manifest.json" do
38+
subject do
39+
Utils.bundle_js_file_path("manifest.json")
40+
end
41+
42+
it { expect(subject).to eq("public/webpack/development/manifest.json") }
43+
end
3144
end
3245

3346
context "Without Webpacker enabled" do

0 commit comments

Comments
 (0)