add and import publicpath.js

This commit is contained in:
surtur 2021-02-23 04:32:50 +01:00
parent bf1314ecbd
commit 17cbcbfbcf
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D
2 changed files with 12 additions and 1 deletions

@ -1,5 +1,6 @@
import './jquery.js'
import 'jquery';
import './publicpath.js';
import './jquery.js'
window.$ = require('jquery');
import 'bootstrap';
import './site.js';

10
wwwroot/js/publicpath.js Normal file

@ -0,0 +1,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(/\/[^/]*?\/[^/]*?$/, '/');
}