From a7e080e4b19a7e46659500fa2378a1a51309e8d7 Mon Sep 17 00:00:00 2001 From: "Alessandro (Ale) Segala" <43508+ItalyPaleAle@users.noreply.github.com> Date: Sun, 31 Mar 2019 22:45:57 -0700 Subject: [PATCH 1/2] InlineChunkHtmlPlugin works with empty publicPath --- packages/react-dev-utils/InlineChunkHtmlPlugin.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/react-dev-utils/InlineChunkHtmlPlugin.js b/packages/react-dev-utils/InlineChunkHtmlPlugin.js index e38ed53d3fb..dc70ccc8135 100644 --- a/packages/react-dev-utils/InlineChunkHtmlPlugin.js +++ b/packages/react-dev-utils/InlineChunkHtmlPlugin.js @@ -17,7 +17,7 @@ class InlineChunkHtmlPlugin { if (tag.tagName !== 'script' || !(tag.attributes && tag.attributes.src)) { return tag; } - const scriptName = tag.attributes.src.replace(publicPath, ''); + const scriptName = publicPath ? tag.attributes.src.replace(publicPath, '') : tag.attributes.src; if (!this.tests.some(test => scriptName.match(test))) { return tag; } @@ -29,8 +29,8 @@ class InlineChunkHtmlPlugin { } apply(compiler) { - let publicPath = compiler.options.output.publicPath; - if (!publicPath.endsWith('/')) { + let publicPath = compiler.options.output.publicPath || ''; + if (publicPath.length > 0 && !publicPath.endsWith('/')) { publicPath += '/'; } From 51015cb5b31a2c080a92315114813d8b4e0b2e14 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Mon, 1 Apr 2019 13:35:29 -0700 Subject: [PATCH 2/2] Update as requested Co-Authored-By: ItalyPaleAle <43508+ItalyPaleAle@users.noreply.github.com> --- packages/react-dev-utils/InlineChunkHtmlPlugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-dev-utils/InlineChunkHtmlPlugin.js b/packages/react-dev-utils/InlineChunkHtmlPlugin.js index dc70ccc8135..de47f464551 100644 --- a/packages/react-dev-utils/InlineChunkHtmlPlugin.js +++ b/packages/react-dev-utils/InlineChunkHtmlPlugin.js @@ -30,7 +30,7 @@ class InlineChunkHtmlPlugin { apply(compiler) { let publicPath = compiler.options.output.publicPath || ''; - if (publicPath.length > 0 && !publicPath.endsWith('/')) { + if (publicPath && !publicPath.endsWith('/')) { publicPath += '/'; }