From 80eefc1a2aa89261cbb045b0c72ad1307f93c4c3 Mon Sep 17 00:00:00 2001 From: Stefan Frede Date: Fri, 4 Sep 2020 09:06:39 +0200 Subject: [PATCH 1/2] fix: check for http in baseUrl `path.posix.join` can't be used with URLs. --- plugins/plugin-webpack/plugin.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/plugin-webpack/plugin.js b/plugins/plugin-webpack/plugin.js index 77cbfdbd1a..4885dd3d39 100644 --- a/plugins/plugin-webpack/plugin.js +++ b/plugins/plugin-webpack/plugin.js @@ -2,6 +2,7 @@ const crypto = require("crypto"); const fs = require("fs"); const glob = require("glob"); const path = require("path"); +const url = require("url"); const webpack = require("webpack"); const MiniCssExtractPlugin = require("mini-css-extract-plugin"); const TerserJSPlugin = require("terser-webpack-plugin"); @@ -67,7 +68,9 @@ function emitHTMLFiles({ doms, jsEntries, stats, baseUrl, buildDirectory }) { for (const jsFile of jsFiles) { const scriptEl = dom.window.document.createElement("script"); - scriptEl.src = path.posix.join(baseUrl, jsFile); + scriptEl.src = baseUrl.startsWith('http') + ? url.resolve(baseUrl, jsFile) + : path.posix.join(baseUrl, jsFile); // insert _before_ so the relative order of these scripts is maintained insertBefore(scriptEl, originalScriptEl); } From fb90d1021b7c3469cdc17d45831066eb7b6f6773 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Mon, 7 Sep 2020 09:38:45 -0700 Subject: [PATCH 2/2] Update plugin.js --- plugins/plugin-webpack/plugin.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/plugin-webpack/plugin.js b/plugins/plugin-webpack/plugin.js index 4885dd3d39..8262a8acbf 100644 --- a/plugins/plugin-webpack/plugin.js +++ b/plugins/plugin-webpack/plugin.js @@ -68,7 +68,7 @@ function emitHTMLFiles({ doms, jsEntries, stats, baseUrl, buildDirectory }) { for (const jsFile of jsFiles) { const scriptEl = dom.window.document.createElement("script"); - scriptEl.src = baseUrl.startsWith('http') + scriptEl.src = url.parse(baseUrl).protocol ? url.resolve(baseUrl, jsFile) : path.posix.join(baseUrl, jsFile); // insert _before_ so the relative order of these scripts is maintained