From 8e4ff4de901d846ac99d37ebf212b12e9687ed5e Mon Sep 17 00:00:00 2001 From: Sanjaiyan Parthipan Date: Mon, 12 Sep 2022 01:37:46 +0530 Subject: [PATCH] perf: render pages asynchronously (#1320) Co-authored-by: Divyansh Singh <40380293+brc-dd@users.noreply.github.com> --- src/node/build/build.ts | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/node/build/build.ts b/src/node/build/build.ts index 3de81d06..853cc1a3 100644 --- a/src/node/build/build.ts +++ b/src/node/build/build.ts @@ -65,18 +65,20 @@ export async function build( const pages = ['404.md', ...siteConfig.pages] - for (const page of pages) { - await renderPage( - render, - siteConfig, - page, - clientResult, - appChunk, - cssChunk, - pageToHashMap, - hashMapString + await Promise.all( + pages.map((page) => + renderPage( + render, + siteConfig, + page, + clientResult, + appChunk, + cssChunk, + pageToHashMap, + hashMapString + ) ) - } + ) } catch (e) { spinner.stopAndPersist({ symbol: failMark