From 854a355eacac9af96b78caa3991931001a53c189 Mon Sep 17 00:00:00 2001 From: pacexy Date: Fri, 23 Dec 2022 22:43:14 +0800 Subject: [PATCH 1/2] fix css resources not being loaded --- packages/next/build/webpack/plugins/flight-manifest-plugin.ts | 4 ++-- 1 file changed, 2 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..2148162b7c800 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 { join, relative } from 'path' import { isClientComponentModule, regexCSS } from '../loaders/utils' import { @@ -349,7 +349,7 @@ export class FlightManifestPlugin { entryName: string | undefined | null ) => { if (entryName?.startsWith('app/')) { - const key = this.appDir + entryName.slice(3) + const key = join(this.appDir, entryName.slice(3)) entryCSSFiles[key] = files.concat(entryCSSFiles[key] || []) } } From d7830ccad174e1f5a1b61ed9460166245582b274 Mon Sep 17 00:00:00 2001 From: pacexy Date: Fri, 23 Dec 2022 22:55:59 +0800 Subject: [PATCH 2/2] add test --- test/e2e/app-dir/app/index.test.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/e2e/app-dir/app/index.test.ts b/test/e2e/app-dir/app/index.test.ts index 3810684dd788b..55ce65c7fd8d3 100644 --- a/test/e2e/app-dir/app/index.test.ts +++ b/test/e2e/app-dir/app/index.test.ts @@ -1413,6 +1413,12 @@ createNextDescribe( }) describe('special entries', () => { + it('should include css imported in layout.js', async () => { + const html = await next.render('/') + // The link tag should be included together with layout + expect(html).toMatch(/ { const html = await next.render('/loading-bug/hi') // The link tag should be included together with loading