Skip to content

Commit

Permalink
🐛 Fix bug that prevents loading assets with webpacker-dev-server
Browse files Browse the repository at this point in the history
Issue reactjs#739

In certain circumstances `webpacker-dev-server` includes the full path
(protocol and host with port) in the paths generated for the
packs/manifest.json file. This addition removes the protocol, host, and
port from the asset path when present allowing assets to be correctly
loaded.
  • Loading branch information
joeyparis authored Nov 6, 2017
1 parent b3fac2c commit 649b1b6
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/react/server_rendering/webpacker_manifest_container.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def find_asset(logical_path)
asset_path = Webpacker.manifest.lookup(logical_path).to_s
if Webpacker.dev_server.running?
ds = Webpacker.dev_server
# Remove the protocol and host from the asset path. Sometimes webpacker includes this, sometimes it does not
asset_path.slice!("#{ds.protocol}://#{ds.host_with_port}")
dev_server_asset = open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read
dev_server_asset.sub!(CLIENT_REQUIRE, '//\0')
dev_server_asset
Expand Down

0 comments on commit 649b1b6

Please sign in to comment.