Skip to content

Commit 9529a87

Browse files
authored
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
1 parent 8562680 commit 9529a87

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

packages/next/src/build/webpack-config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,10 @@ export default async function getBaseWebpackConfig(
18971897
new NextFontManifestPlugin({
18981898
appDir,
18991899
}),
1900-
!dev && isClient && new MergeCssChunksPlugin(),
1900+
!dev &&
1901+
isClient &&
1902+
config.experimental.mergeCssChunks &&
1903+
new MergeCssChunksPlugin(),
19011904
!dev &&
19021905
isClient &&
19031906
new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)(

packages/next/src/server/config-schema.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
276276
linkNoTouchStart: z.boolean().optional(),
277277
manualClientBasePath: z.boolean().optional(),
278278
middlewarePrefetch: z.enum(['strict', 'flexible']).optional(),
279+
mergeCssChunks: z.boolean().optional(),
279280
navigationRAF: z.boolean().optional(),
280281
nextScriptWorkers: z.boolean().optional(),
281282
// The critter option is unknown, use z.any() here

packages/next/src/server/config-shared.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,11 @@ export interface ExperimentalConfig {
193193
swrDelta?: SwrDelta
194194
middlewarePrefetch?: 'strict' | 'flexible'
195195
manualClientBasePath?: boolean
196+
/**
197+
* This will enable a plugin that attempts to keep CSS entries below a certain amount
198+
* by merging smaller chunks into larger ones
199+
*/
200+
mergeCssChunks?: boolean
196201
/**
197202
* @deprecated use config.cacheHandler instead
198203
*/
@@ -904,6 +909,7 @@ export const defaultConfig: NextConfig = {
904909
missingSuspenseWithCSRBailout: true,
905910
optimizeServerReact: false,
906911
useEarlyImport: false,
912+
mergeCssChunks: true,
907913
},
908914
}
909915

0 commit comments

Comments
 (0)