diff --git a/.changeset/red-crabs-breathe.md b/.changeset/red-crabs-breathe.md new file mode 100644 index 000000000000..1225277e00a9 --- /dev/null +++ b/.changeset/red-crabs-breathe.md @@ -0,0 +1,17 @@ +--- +'astro': patch +--- + +Limits the number of pages logged by default to 100 per route. + +If there are more than 100 pages it will log the first 100 pages and then log a summary of the total number of pages. + +For example: + +```sh +10:08:26 ├─ /blog/article-98/index.html (+0ms) +10:08:26 ├─ /blog/article-99/index.html (+1ms) +10:08:26 └─ ...rendering 100 more paths. Done. (+63ms) +``` + +To see the full list of pages rendered, enable debug logging using the `--verbose` flag. diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index e394dc156de5..77e4e87eba55 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -199,7 +199,7 @@ async function generatePage( pipeline: BuildPipeline ) { // prepare information we need - const { config, internals, logger } = pipeline; + const { config, logger } = pipeline; const pageModulePromise = ssrEntry.page; // Calculate information of the page, like scripts, links and styles @@ -223,6 +223,9 @@ async function generatePage( styles, mod: pageModule, }; + + const maxPathsToLog = 100; + // Now we explode the routes. A route render itself, and it can render its fallbacks (i18n routing) for (const route of eachRouteInRouteData(pageData)) { const icon = @@ -234,18 +237,39 @@ async function generatePage( const paths = await getPathsForRoute(route, pageModule, pipeline, builtPaths); let timeStart = performance.now(); let prevTimeEnd = timeStart; + + const shouldTruncate = + pipeline.logger.options.level !== 'debug' && paths.length > maxPathsToLog; + for (let i = 0; i < paths.length; i++) { const path = paths[i]; pipeline.logger.debug('build', `Generating: ${path}`); - const filePath = getOutputFilename(config, path, pageData.route.type); - const lineIcon = i === paths.length - 1 ? '└─' : '├─'; - logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false); + if (i < maxPathsToLog) { + const filePath = getOutputFilename(config, path, pageData.route.type); + const lineIcon = i === paths.length - 1 ? '└─' : '├─'; + logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false); + } await generatePath(path, pipeline, generationOptions, route); + if (!shouldTruncate || i < maxPathsToLog) { + const timeEnd = performance.now(); + const timeChange = getTimeStat(prevTimeEnd, timeEnd); + const timeIncrease = `(+${timeChange})`; + logger.info('SKIP_FORMAT', ` ${dim(timeIncrease)}`); + prevTimeEnd = timeEnd; + } + if (shouldTruncate && i === maxPathsToLog && paths.length > maxPathsToLog) { + logger.info( + null, + ` ${blue('└─')} ${dim(`...rendering ${paths.length - maxPathsToLog} more paths.`)}`, + false + ); + } + } + if (shouldTruncate) { const timeEnd = performance.now(); const timeChange = getTimeStat(prevTimeEnd, timeEnd); const timeIncrease = `(+${timeChange})`; - logger.info('SKIP_FORMAT', ` ${dim(timeIncrease)}`); - prevTimeEnd = timeEnd; + logger.info('SKIP_FORMAT', ` ${green('Done.')} ${dim(timeIncrease)}`); } } }