mirror of https://github.com/webpack/webpack.git
access document through window
This commit is contained in:
parent
6807bb6f6d
commit
94973fd240
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue