diff --git a/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb b/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb index fda63d7e6..d497ccfdd 100644 --- a/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb +++ b/entry_types/scrolled/app/helpers/pageflow_scrolled/react_server_side_rendering_helper.rb @@ -32,6 +32,9 @@ def asset_container_class # see https://github.com/reactjs/react-rails/issues/970#issuecomment-476338244 class WebpackerSplitChunksManifestContainer < React::ServerRendering::WebpackerManifestContainer + CLIENT_EXEC = + %r{__webpack_exec__\("./node_modules/webpack-dev-server\/client\/index\.js[^"]*"\),} + def find_asset(logical_path) asset_paths = manifest.lookup_pack_with_chunks(logical_path, type: :javascript) @@ -46,7 +49,12 @@ def find_asset(logical_path) asset_path.slice!("#{ds.protocol}://#{ds.host_with_port}") dev_server_asset = URI.open("#{ds.protocol}://#{ds.host_with_port}#{asset_path}").read - dev_server_asset.sub!(CLIENT_REQUIRE, '//\0') + + # Remove webpack-dev-server client code that tries to + # interact with browser globals: + dev_server_asset.sub!(CLIENT_REQUIRE, '//\0') # for Webpack 4 + dev_server_asset.sub!(CLIENT_EXEC, '/*\0*/') # for Webpack 5 + dev_server_asset end else