summaryrefslogtreecommitdiffstats
path: root/web_src/js/publicpath.js
blob: 38865aa6669e3b3d1853198c2ac47887a5eda424 (plain)
1
2
3
4
5
6
7
8
9
10
// This sets up the URL prefix used in webpack's chunk loading.
// This file must be imported before any lazy-loading is being attempted.
const {StaticUrlPrefix} = window.config;

if (StaticUrlPrefix) {
  __webpack_public_path__ = StaticUrlPrefix.endsWith('/') ? StaticUrlPrefix : `${StaticUrlPrefix}/`;
} else {
  const url = new URL(document.currentScript.src);
  __webpack_public_path__ = url.pathname.replace(/\/[^/]*?\/[^/]*?$/, '/');
}