Skip to content

Commit b8dfdbd

Browse files
committed
fix(Build): Use public_path script while also having publicPath set to auto.
We still need to use the ``src/public_path.js`` script as first import in our bundles to correctly resolve the loading path for chunks. publicPath set to auto does not work in certain environments (e.g. the Plone resource registry). Partially reverts 1b61431, "Use automatic publicPath determination instead of manually setting it."
1 parent 5de91cc commit b8dfdbd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

src/public_path.js

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1-
// BBB: Replaced by: ``output.publicPath = "auto"``
2-
// NOTE: This file will be removed in an upcoming release.
31
// NOTE: Import this file before any other files
42
// Overwrite path to load resources or use default one.
5-
__webpack_public_path__ = // eslint-disable-line no-undef
6-
window.__patternslib_public_path__ || document.currentScript.src + "/../";
3+
__webpack_public_path__ = window.__patternslib_public_path__; // eslint-disable-line no-undef
4+
// eslint-disable-next-line no-undef
5+
if (!__webpack_public_path__) {
6+
// Get chunks path from current script.
7+
let src = document.currentScript?.src;
8+
if (src) {
9+
src = src.split("/");
10+
src.pop();
11+
__webpack_public_path__ = src.join("/") + "/"; // eslint-disable-line no-undef
12+
}
13+
}

0 commit comments

Comments
 (0)