Add a flag to disable MergeCssChunksPlugin (#62746)

This is currently on by default, but this adds a flag to allow disabling
it if it causes issues with your application's CSS.

Closes NEXT-2664
This commit is contained in:
Zack Tanner 2024-03-01 13:44:28 -08:00 committed by GitHub
parent 8562680f23
commit 9529a874bd
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 11 additions and 1 deletions

View file

@ -1897,7 +1897,10 @@ export default async function getBaseWebpackConfig(
new NextFontManifestPlugin({ new NextFontManifestPlugin({
appDir, appDir,
}), }),
!dev && isClient && new MergeCssChunksPlugin(), !dev &&
isClient &&
config.experimental.mergeCssChunks &&
new MergeCssChunksPlugin(),
!dev && !dev &&
isClient && isClient &&
new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)( new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)(

View file

@ -276,6 +276,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
linkNoTouchStart: z.boolean().optional(), linkNoTouchStart: z.boolean().optional(),
manualClientBasePath: z.boolean().optional(), manualClientBasePath: z.boolean().optional(),
middlewarePrefetch: z.enum(['strict', 'flexible']).optional(), middlewarePrefetch: z.enum(['strict', 'flexible']).optional(),
mergeCssChunks: z.boolean().optional(),
navigationRAF: z.boolean().optional(), navigationRAF: z.boolean().optional(),
nextScriptWorkers: z.boolean().optional(), nextScriptWorkers: z.boolean().optional(),
// The critter option is unknown, use z.any() here // The critter option is unknown, use z.any() here

View file

@ -193,6 +193,11 @@ export interface ExperimentalConfig {
swrDelta?: SwrDelta swrDelta?: SwrDelta
middlewarePrefetch?: 'strict' | 'flexible' middlewarePrefetch?: 'strict' | 'flexible'
manualClientBasePath?: boolean manualClientBasePath?: boolean
/**
* This will enable a plugin that attempts to keep CSS entries below a certain amount
* by merging smaller chunks into larger ones
*/
mergeCssChunks?: boolean
/** /**
* @deprecated use config.cacheHandler instead * @deprecated use config.cacheHandler instead
*/ */
@ -904,6 +909,7 @@ export const defaultConfig: NextConfig = {
missingSuspenseWithCSRBailout: true, missingSuspenseWithCSRBailout: true,
optimizeServerReact: false, optimizeServerReact: false,
useEarlyImport: false, useEarlyImport: false,
mergeCssChunks: true,
}, },
} }