perf(vite): avoid duplicate resolve operation (#24736)

This commit is contained in:
Michael Brevard 2023-12-14 12:32:22 +02:00 committed by GitHub
parent 1bf1edf66d
commit 62df8f086d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,9 +27,10 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = [])
} }
} }
const manifestFile = resolve(clientDist, 'manifest.json')
const clientManifest = ctx.nuxt.options.dev const clientManifest = ctx.nuxt.options.dev
? devClientManifest ? devClientManifest
: await fse.readJSON(resolve(clientDist, 'manifest.json')) : await fse.readJSON(manifestFile)
const buildAssetsDir = withTrailingSlash(withoutLeadingSlash(ctx.nuxt.options.app.buildAssetsDir)) const buildAssetsDir = withTrailingSlash(withoutLeadingSlash(ctx.nuxt.options.app.buildAssetsDir))
const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`) const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`)
@ -63,6 +64,6 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = [])
await fse.writeFile(resolve(serverDist, 'client.manifest.mjs'), 'export default ' + JSON.stringify(manifest, null, 2), 'utf8') await fse.writeFile(resolve(serverDist, 'client.manifest.mjs'), 'export default ' + JSON.stringify(manifest, null, 2), 'utf8')
if (!ctx.nuxt.options.dev) { if (!ctx.nuxt.options.dev) {
await fse.rm(resolve(clientDist, 'manifest.json'), { force: true }) await fse.rm(manifestFile, { force: true })
} }
} }