aboutsummaryrefslogtreecommitdiffstats
path: root/web_src/js/publicPath.js
blob: 5d277e442acb5d3e8a6589b9c1965a0b2e62dfa2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
/* This sets up webpack's chunk loading to load resources from the same
  directory where it loaded index.js from. This file must be imported
  before any lazy-loading is being attempted. */

if (document.currentScript && document.currentScript.src) {
  const url = new URL(document.currentScript.src);
  __webpack_public_path__ = `${url.pathname.replace(/\/[^/]*$/, '')}/`;
} else {
  // compat: IE11
  const script = document.querySelector('script[src*="/index.js"]');
  __webpack_public_path__ = `${script.getAttribute('src').replace(/\/[^/]*$/, '')}/`;
}