fix(andreknie.de): close accessibility and performance review gaps
This commit is contained in:
@@ -1,18 +1,27 @@
|
||||
import { readdirSync, statSync } from 'node:fs'
|
||||
import { join } from 'node:path'
|
||||
import { basename, join } from 'node:path'
|
||||
|
||||
const assetsDir = join(process.cwd(), 'dist', 'assets')
|
||||
const files = readdirSync(assetsDir)
|
||||
const entry = files.find(file => /^index-[^/]+\.js$/.test(file))
|
||||
const detailChunk = files.find(file => /^_virtual_content-details-[^/]+\.js$/.test(file))
|
||||
const maxInitialBytes = 700 * 1024
|
||||
const detailSlugs = ['posts', 'kniepunkt'].flatMap(type =>
|
||||
readdirSync(join(process.cwd(), 'content', type))
|
||||
.filter(file => file.endsWith('.md'))
|
||||
.map(file => basename(file, '.md')),
|
||||
)
|
||||
const missingDetailChunks = detailSlugs.filter(
|
||||
slug => !files.some(file => file.startsWith(`${slug}-`) && file.endsWith('.js')),
|
||||
)
|
||||
const maxInitialBytes = 400 * 1024
|
||||
|
||||
if (!entry) throw new Error('Kein initialer JavaScript-Entry-Chunk gefunden.')
|
||||
if (!detailChunk) throw new Error('Kein separater Content-Detail-Chunk gefunden.')
|
||||
if (missingDetailChunks.length > 0) {
|
||||
throw new Error(`Fehlende Content-Detail-Chunks: ${missingDetailChunks.join(', ')}`)
|
||||
}
|
||||
|
||||
const entryBytes = statSync(join(assetsDir, entry)).size
|
||||
if (entryBytes > maxInitialBytes) {
|
||||
throw new Error(`Initialer JS-Chunk ist zu groß: ${entryBytes} Bytes (Limit ${maxInitialBytes}).`)
|
||||
}
|
||||
|
||||
console.log(`Bundle-Prüfung: ${entry}=${entryBytes} Bytes, Detail-Chunk=${detailChunk}`)
|
||||
console.log(`Bundle-Prüfung: ${entry}=${entryBytes} Bytes, Detail-Chunks=${detailSlugs.length}`)
|
||||
|
||||
Reference in New Issue
Block a user