From 9a505bd649ac6669f09f5e4a1072c10cd0a35895 Mon Sep 17 00:00:00 2001 From: Shu Ding Date: Fri, 23 Dec 2022 20:25:56 +0100 Subject: [PATCH] fix filepath separator in __entry_css_files__ --- .../next/build/webpack/plugins/flight-manifest-plugin.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/next/build/webpack/plugins/flight-manifest-plugin.ts b/packages/next/build/webpack/plugins/flight-manifest-plugin.ts index 9ac29f51266af..26192a312a9d0 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] || []) } }