perf(vite): simplify manifest property acccess (#24715)

This commit is contained in:
Michael Brevard 2023-12-14 13:25:20 +02:00 committed by GitHub
parent 628dc716b5
commit 4e0d2c073f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,12 +36,13 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = [])
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`) const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)
for (const key in clientManifest) { for (const key in clientManifest) {
if (clientManifest[key].file) { const entry = clientManifest[key]
clientManifest[key].file = clientManifest[key].file.replace(BASE_RE, '') if (entry.file) {
entry.file = entry.file.replace(BASE_RE, '')
} }
for (const item of ['css', 'assets']) { for (const item of ['css', 'assets']) {
if (clientManifest[key][item]) { if (entry[item]) {
clientManifest[key][item] = clientManifest[key][item].map((i: string) => i.replace(BASE_RE, '')) entry[item] = entry[item].map((i: string) => i.replace(BASE_RE, ''))
} }
} }
} }