diff --git a/packages/vite/src/manifest.ts b/packages/vite/src/manifest.ts index 154d50edbe..00a4cf98cf 100644 --- a/packages/vite/src/manifest.ts +++ b/packages/vite/src/manifest.ts @@ -36,12 +36,13 @@ export async function writeManifest (ctx: ViteBuildContext, css: string[] = []) const BASE_RE = new RegExp(`^${escapeRE(buildAssetsDir)}`) for (const key in clientManifest) { - if (clientManifest[key].file) { - clientManifest[key].file = clientManifest[key].file.replace(BASE_RE, '') + const entry = clientManifest[key] + if (entry.file) { + entry.file = entry.file.replace(BASE_RE, '') } for (const item of ['css', 'assets']) { - if (clientManifest[key][item]) { - clientManifest[key][item] = clientManifest[key][item].map((i: string) => i.replace(BASE_RE, '')) + if (entry[item]) { + entry[item] = entry[item].map((i: string) => i.replace(BASE_RE, '')) } } }