Skip to content
This repository was archived by the owner on Jul 6, 2025. It is now read-only.

Commit 9606bcd

Browse files
committed
Improve SSG console message
1 parent 44d06a7 commit 9606bcd

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

server/aleph.ts

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ import { Analyzer } from './analyzer.ts'
2525
import { cache } from './cache.ts'
2626
import { defaultConfig, fixConfig, getDefaultImportMap, loadConfig, loadImportMap } from './config.ts'
2727
import {
28-
checkDenoVersion, clearBuildCache, decoder, encoder, getAlephPkgUri,
29-
getSourceType, isLocalhostUrl, loadPlugin, moduleExclude, toLocalPath, toRelativePath,
28+
checkDenoVersion, clearBuildCache, decoder, encoder, formatBytesWithColor, getAlephPkgUri,
29+
getSourceType, isLocalhostUrl, moduleExclude, toLocalPath, toRelativePath,
3030
} from './helper.ts'
3131
import { getContentType } from './mime.ts'
3232
import { buildHtml, Renderer } from './renderer.ts'
@@ -1534,26 +1534,35 @@ export class Aleph implements IAleph {
15341534
}
15351535

15361536
// render route pages
1537+
let pageIndex = 0
15371538
const req = new Request('http://localhost/')
15381539
await Promise.all(Array.from(paths).map(loc => ([loc, ...locales.map(locale => ({ ...loc, pathname: '/' + locale + loc.pathname }))])).flat().map(async ({ pathname, search }) => {
15391540
if (this.#isSSRable(pathname)) {
15401541
const [router, nestedModules] = this.#pageRouting.createRouter({ pathname, search })
15411542
if (router.routePath !== '') {
1543+
const ms = new Measure()
15421544
const href = router.toString()
15431545
const [html, data] = await this.#renderPage(req, router, nestedModules)
1544-
await ensureTextFile(join(outputDir, pathname, 'index.html' + (search || '')), html)
1545-
if (data) {
1546-
const dataFile = join(
1547-
outputDir,
1548-
`_aleph/data/${util.btoaUrl(href)}.json`
1549-
)
1550-
await ensureTextFile(dataFile, JSON.stringify(data))
1546+
await Promise.all([
1547+
ensureTextFile(join(outputDir, pathname, 'index.html' + (search || '')), html),
1548+
data ? ensureTextFile(join(outputDir, `_aleph/data/${util.btoaUrl(href)}.json`), JSON.stringify(data)) : Promise.resolve()
1549+
])
1550+
ms.stop(`SSR ${href} (${formatBytesWithColor(html.length)})`)
1551+
if (pageIndex == 0) {
1552+
console.log('▲ SSG')
1553+
}
1554+
if (pageIndex <= 20) {
1555+
console.log(' ', href, dim('•'), formatBytesWithColor(html.length))
15511556
}
1552-
log.debug('SSR', href, dim('• ' + util.formatBytes(html.length)))
1557+
pageIndex++
15531558
}
15541559
}
15551560
}))
15561561

1562+
if (pageIndex > 20) {
1563+
console.log(` ... total ${pageIndex} pages`)
1564+
}
1565+
15571566
// render 404 page
15581567
{
15591568
const [router, nestedModules] = this.#pageRouting.createRouter({ pathname: '/404' })

0 commit comments

Comments
 (0)