Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
endiliey committed Dec 13, 2019
1 parent 1e1d329 commit 7123eb3
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions packages/docusaurus/src/client/docusaurus.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,15 @@ const docusaurus = {
}, []);

// Prefetch all webpack chunk assets file needed
const chunkAssetsNeeded = chunkNamesNeeded.reduce((arr, chunkName) => {
chunkNamesNeeded.forEach(chunkName => {
// "__webpack_require__.gca" is a custom function provided by ChunkAssetPlugin
// Pass it the chunkName or chunkId you want to load.
// For example: if you have a chunk named "my-chunk-name" that will map to "/0a84b5e7.c8e35c7a.js" as its corresponding output path
// __webpack_require__.gca("my-chunk-name") will return "/0a84b5e7.c8e35c7a.js"
// 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 chunkAssets = __webpack_require__.gca(chunkName) || [];
return arr.concat(chunkAssets);
}, []);

chunkAssetsNeeded.map(prefetchHelper);
const chunkAsset = __webpack_require__.gca(chunkName);
if (chunkAsset) {
prefetchHelper(chunkAsset);
}
});
return true;
},
preload: routePath => {
Expand Down

0 comments on commit 7123eb3

Please sign in to comment.