diff --git a/src/loader.js b/src/loader.js index 6dac3261..75dcef13 100644 --- a/src/loader.js +++ b/src/loader.js @@ -188,6 +188,11 @@ export function pitch(request) { if (publicPath === "auto") { publicPath = AUTO_PUBLIC_PATH; + } else if (typeof publicPath === "function") { + // `hash` property is not available in this context, Webpack itself just set `hash` with + // an arbitrary value. + // See: https://github.com/webpack/webpack/blob/main/lib/runtime/PublicPathRuntimeModule.js#L19-L27 + publicPath = publicPath({ hash: "XXXX" }); } if ( diff --git a/test/__snapshots__/public-path.test.js.snap b/test/__snapshots__/public-path.test.js.snap new file mode 100644 index 00000000..bae6db28 --- /dev/null +++ b/test/__snapshots__/public-path.test.js.snap @@ -0,0 +1,19 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`public path should work with function output.publicPath: DOM 1`] = ` +"
+