Skip to content

Commit

Permalink
feat: Move current page to pages[0]
Browse files Browse the repository at this point in the history
  • Loading branch information
answershuto committed Jul 25, 2022
1 parent d7a1b57 commit 8df5edd
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions packages/plugin-rax-pha/src/plugins/AppToManifestPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,17 @@ module.exports = class {
})
.forEach(({ source, entryName, __frameIndex }) => {
let copyManifestJSON = cloneDeep(manifestJSON);
copyManifestJSON.pages = copyManifestJSON.pages.filter((page) => {
// has frames
if (__frameIndex === 0) {
return !!(page.frames && page.frames[0] && page.frames[0].source === source);
} else {
return page.source === source;

// Move current page to pages[0].
for (let i = 0; i < copyManifestJSON.pages.length; i++) {
const page = copyManifestJSON.pages[i];
console.log('page[i].source === source', page.source, source);
if (page.source === source || (__frameIndex === 0 && (page.frames && page.frames[0] && page.frames[0].source === source))) {
console.log('i=========', i);
copyManifestJSON.pages.unshift(copyManifestJSON.pages.splice(i, 1));
break;
}
});
}

const { pages } = copyManifestJSON;
// take out the page data prefetch and assign it to the root node
Expand Down

0 comments on commit 8df5edd

Please sign in to comment.