diff --git a/packages/next/build/webpack/plugins/flight-manifest-plugin.ts b/packages/next/build/webpack/plugins/flight-manifest-plugin.ts index 9ac29f51266af6d..26192a312a9d0f7 100644 --- a/packages/next/build/webpack/plugins/flight-manifest-plugin.ts +++ b/packages/next/build/webpack/plugins/flight-manifest-plugin.ts @@ -7,7 +7,7 @@ import { webpack, sources } from 'next/dist/compiled/webpack/webpack' import { FLIGHT_MANIFEST } from '../../../shared/lib/constants' -import { relative } from 'path' +import { relative, sep } from 'path' import { isClientComponentModule, regexCSS } from '../loaders/utils' import { @@ -349,7 +349,9 @@ export class FlightManifestPlugin { entryName: string | undefined | null ) => { if (entryName?.startsWith('app/')) { - const key = this.appDir + entryName.slice(3) + // The `key` here should be the absolute file path but without extension. + // We need to replace the separator in the entry name to match the system separator. + const key = this.appDir + entryName.slice(3).replace(/\//g, sep) entryCSSFiles[key] = files.concat(entryCSSFiles[key] || []) } }