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";
|
const publicPath = this.compilation.outputOptions.publicPath || "auto";
|
||||||
if (publicPath === "auto") {
|
if (publicPath === "auto") {
|
||||||
return `${RuntimeGlobals.publicPath} = (() => {
|
return `${RuntimeGlobals.publicPath} = (() => {
|
||||||
if ("currentScript" in document) {
|
if ("currentScript" in window.document) {
|
||||||
return document.currentScript.src.replace(/[^\\/]+$/, "");
|
return window.document.currentScript.src.replace(/[^\\/]+$/, "");
|
||||||
} else {
|
} else {
|
||||||
throw new Error("Webpack: Auto public path is not supported in modules or when 'document.currentScript' is unavailable. Set 'publicPath' config explicitly.");
|
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