From 94973fd240c52cc5ac86c1601d340c6a1e29400e Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Sun, 2 Aug 2020 20:49:48 -0700 Subject: [PATCH] access document through window --- lib/runtime/PublicPathRuntimeModule.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/runtime/PublicPathRuntimeModule.js b/lib/runtime/PublicPathRuntimeModule.js index a7429db71..62eb162c3 100644 --- a/lib/runtime/PublicPathRuntimeModule.js +++ b/lib/runtime/PublicPathRuntimeModule.js @@ -21,8 +21,8 @@ class PublicPathRuntimeModule extends RuntimeModule { const publicPath = this.compilation.outputOptions.publicPath || "auto"; if (publicPath === "auto") { return `${RuntimeGlobals.publicPath} = (() => { - if ("currentScript" in document) { - return document.currentScript.src.replace(/[^\\/]+$/, ""); + if ("currentScript" in window.document) { + return window.document.currentScript.src.replace(/[^\\/]+$/, ""); } else { throw new Error("Webpack: Auto public path is not supported in modules or when 'document.currentScript' is unavailable. Set 'publicPath' config explicitly."); }