extract chunkMap to json file, and read it.
webpack | chunks-extract-plugin |
---|---|
5.x | 2.x |
4.x | 1.x |
javascript file
var url = __webpack_require__.p + __webpack_require__.u(chunkId);
javascript file
let fetchSrc
new Promise(function(resolve, reject) {
fetch(__webpack_require__.p + 'routes.json')
.then(response => response.json())
.then(response => {
fetchSrc = __webpack_require__.p + response[chunkId] + ".chunk.js";
return resolve();
})
.catch(() => resolve());
}).then(function(){
var url = fetchSrc;
// code
});
json file
{"0":"0-2b10c240", "1":"0-2b10c240"}
MIT Licensed Copyright (c) 2023 Iftek