fix(v2): filter out invalid prefetch script without contenthash (#2167)

This commit is contained in:
Endi 2020-01-01 17:49:12 +07:00 committed by Yangshun Tay
parent 75f5bb4d23
commit 6f6f756d70

View file

@ -58,7 +58,10 @@ const docusaurus = {
// Pass it the chunkName or chunkId you want to load and it will return the URL for that chunk
// eslint-disable-next-line no-undef
const chunkAsset = __webpack_require__.gca(chunkName);
if (chunkAsset) {
// In some cases, webpack might decide to optimize further & hence the chunk asssets are merged to another chunk/previous chunk
// Hence, we can safely filter it out/ dont need to load it
if (chunkAsset && !/undefined/.test(chunkAsset)) {
prefetchHelper(chunkAsset);
}
});