Skip to content

Commit 00b2113

Browse files
authored
Fix CSS resource path not matched in __entry_css_files__ (#44310)
Currently we use `this.appDir + entryName` as the key of app entries. The `appDir` part is an absolute path which contains `\` in Windows, but `entryName` is a general entry name for Webpack, like `app/page`. A quick fix is to replace all `/` in the entry name with the current system separator. Confirmed that it fixed the problem in Windows. ## Bug - [ ] Related issues linked using `fixes #number` - [ ] Integration tests added - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Feature - [ ] Implements an existing feature request or RFC. Make sure the feature request has been accepted for implementation before opening a PR. - [ ] Related issues linked using `fixes #number` - [ ] [e2e](https://github.com/vercel/next.js/blob/canary/contributing/core/testing.md#writing-tests-for-nextjs) tests added - [ ] Documentation added - [ ] Telemetry added. In case of a feature if it's used or not. - [ ] Errors have a helpful link attached, see [`contributing.md`](https://github.com/vercel/next.js/blob/canary/contributing.md) ## Documentation / Examples - [ ] Make sure the linting passes by running `pnpm build && pnpm lint` - [ ] The "examples guidelines" are followed from [our contributing doc](https://github.com/vercel/next.js/blob/canary/contributing/examples/adding-examples.md)
1 parent fd0d0f5 commit 00b2113

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

packages/next/build/webpack/plugins/flight-manifest-plugin.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import { webpack, sources } from 'next/dist/compiled/webpack/webpack'
99
import { FLIGHT_MANIFEST } from '../../../shared/lib/constants'
10-
import { relative } from 'path'
10+
import { relative, sep } from 'path'
1111
import { isClientComponentModule, regexCSS } from '../loaders/utils'
1212

1313
import {
@@ -349,7 +349,9 @@ export class FlightManifestPlugin {
349349
entryName: string | undefined | null
350350
) => {
351351
if (entryName?.startsWith('app/')) {
352-
const key = this.appDir + entryName.slice(3)
352+
// The `key` here should be the absolute file path but without extension.
353+
// We need to replace the separator in the entry name to match the system separator.
354+
const key = this.appDir + entryName.slice(3).replace(/\//g, sep)
353355
entryCSSFiles[key] = files.concat(entryCSSFiles[key] || [])
354356
}
355357
}

0 commit comments

Comments
 (0)