Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should not contain pages css in app dir #44151

Merged
merged 3 commits into from Dec 19, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -345,14 +345,18 @@ export class FlightClientEntryPlugin {
stage: webpack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE_HASH,
},
(assets: webpack.Compilation['assets']) => {
const manifest = JSON.stringify({
...serverCSSManifest,
...edgeServerCSSManifest,
__entry_css__: {
...serverCSSManifest.__entry_css__,
...edgeServerCSSManifest.__entry_css__,
const manifest = JSON.stringify(
{
...serverCSSManifest,
...edgeServerCSSManifest,
__entry_css__: {
...serverCSSManifest.__entry_css__,
...edgeServerCSSManifest.__entry_css__,
},
},
})
null,
this.dev ? 2 : undefined
)
assets[FLIGHT_SERVER_CSS_MANIFEST + '.json'] = new sources.RawSource(
manifest
) as unknown as webpack.sources.RawSource
Expand Down
Expand Up @@ -191,7 +191,9 @@ export class FlightManifestPlugin {
ssrNamedModuleId = `./${ssrNamedModuleId.replace(/\\/g, '/')}`

if (isCSSModule) {
const chunks = [...chunk.files].filter((f) => f.endsWith('.css'))
const chunks = [...chunk.files].filter(
(f) => !f.startsWith('static/css/pages/') && f.endsWith('.css')
)
if (!manifest[resource]) {
manifest[resource] = {
default: {
Expand Down Expand Up @@ -350,7 +352,7 @@ export class FlightManifestPlugin {
})

const file = 'server/' + FLIGHT_MANIFEST
const json = JSON.stringify(manifest)
const json = JSON.stringify(manifest, null, this.dev ? 2 : undefined)

ASYNC_CLIENT_MODULES.clear()

Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/index.test.ts
Expand Up @@ -1315,6 +1315,11 @@ createNextDescribe(
).toBe('rgb(0, 0, 255)')
})

it('should not contain pages css in app dir page', async () => {
const html = await next.render('/css/css-page')
expect(html).not.toContain('/pages/_app.css')
})

if (!isDev) {
it('should not include unused css modules in the page in prod', async () => {
const browser = await next.browser('/css/css-page/unused')
Expand Down