diff --git a/packages/next/build/webpack/config/blocks/css/index.ts b/packages/next/build/webpack/config/blocks/css/index.ts index 14d408ecde26..63ab46b0ddcb 100644 --- a/packages/next/build/webpack/config/blocks/css/index.ts +++ b/packages/next/build/webpack/config/blocks/css/index.ts @@ -360,7 +360,11 @@ export const css = curry(async function css( sideEffects: true, test: regexCssGlobal, issuer: { - and: [ctx.rootDirectory, /\.(js|mjs|jsx|ts|tsx)$/], + or: [ + { and: [ctx.rootDirectory, /\.(js|mjs|jsx|ts|tsx)$/] }, + // Also match the virtual client entry which doesn't have file path + (filePath) => !filePath + ], }, use: getGlobalCssLoader(ctx, lazyPostCSSInitializer), }), diff --git a/packages/next/build/webpack/loaders/next-flight-client-entry-loader.ts b/packages/next/build/webpack/loaders/next-flight-client-entry-loader.ts index 3600de1f1495..a44246691654 100644 --- a/packages/next/build/webpack/loaders/next-flight-client-entry-loader.ts +++ b/packages/next/build/webpack/loaders/next-flight-client-entry-loader.ts @@ -6,12 +6,12 @@ export default async function transformSource(this: any): Promise { modules = modules ? [modules] : [] } - return ( + const code = ( modules .map( - (request: string) => `import(/* webpackMode: "eager" */ '${request}')` + (request: string) => `import(/* webpackMode: "eager" */ '${request}')` ) - .join(';') + + .join(';\n') + ` export const __next_rsc__ = { server: false, @@ -26,4 +26,6 @@ export default async function transformSource(this: any): Promise { ? `export const __N_SSP = true;` : `export const __N_SSG = true;`) ) + + return code } diff --git a/packages/next/build/webpack/plugins/client-entry-plugin.ts b/packages/next/build/webpack/plugins/client-entry-plugin.ts index 34f9f5af60d8..0c78e358a056 100644 --- a/packages/next/build/webpack/plugins/client-entry-plugin.ts +++ b/packages/next/build/webpack/plugins/client-entry-plugin.ts @@ -22,6 +22,7 @@ type Options = { const PLUGIN_NAME = 'ClientEntryPlugin' export const injectedClientEntries = new Map() +const regexCssGlobal = /(?((res, rej) => { diff --git a/test/e2e/app-dir/app/app/dashboard/layout.server.js b/test/e2e/app-dir/app/app/dashboard/layout.server.js index 35bece01cfd7..fd0a79958179 100644 --- a/test/e2e/app-dir/app/app/dashboard/layout.server.js +++ b/test/e2e/app-dir/app/app/dashboard/layout.server.js @@ -1,7 +1,9 @@ +import './style.css' + export default function DashboardLayout(props) { return ( <> -

Dashboard

+

Dashboard

{props.children} ) diff --git a/test/e2e/app-dir/app/app/dashboard/page.server.js b/test/e2e/app-dir/app/app/dashboard/page.server.js index b29dd4fa9f0a..c609b2c219be 100644 --- a/test/e2e/app-dir/app/app/dashboard/page.server.js +++ b/test/e2e/app-dir/app/app/dashboard/page.server.js @@ -2,6 +2,7 @@ export default function DashboardPage(props) { return ( <>

hello from app/dashboard

+

this is green

) } diff --git a/test/e2e/app-dir/app/app/dashboard/style.css b/test/e2e/app-dir/app/app/dashboard/style.css new file mode 100644 index 000000000000..d101ae62882a --- /dev/null +++ b/test/e2e/app-dir/app/app/dashboard/style.css @@ -0,0 +1,3 @@ +.green { + color: green; +} \ No newline at end of file