From 649b1b6aa9309622330ccd1a08706da87215abe3 Mon Sep 17 00:00:00 2001 From: joeyparis Date: Mon, 6 Nov 2017 10:17:07 -0500 Subject: [PATCH] :bug: Fix bug that prevents loading assets with `webpacker-dev-server` Issue #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. --- lib/react/server_rendering/webpacker_manifest_container.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/react/server_rendering/webpacker_manifest_container.rb b/lib/react/server_rendering/webpacker_manifest_container.rb index 926c8f66a..377aeeac0 100644 --- a/lib/react/server_rendering/webpacker_manifest_container.rb +++ b/lib/react/server_rendering/webpacker_manifest_container.rb @@ -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