Skip to content

Commit

Permalink
Add a flag to disable MergeCssChunksPlugin (#62746)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ztanner committed Mar 1, 2024
1 parent 8562680 commit 9529a87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion packages/next/src/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1897,7 +1897,10 @@ export default async function getBaseWebpackConfig(
new NextFontManifestPlugin({
appDir,
}),
!dev && isClient && new MergeCssChunksPlugin(),
!dev &&
isClient &&
config.experimental.mergeCssChunks &&
new MergeCssChunksPlugin(),
!dev &&
isClient &&
new (require('./webpack/plugins/telemetry-plugin').TelemetryPlugin)(
Expand Down
1 change: 1 addition & 0 deletions packages/next/src/server/config-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,7 @@ export const configSchema: zod.ZodType<NextConfig> = z.lazy(() =>
linkNoTouchStart: z.boolean().optional(),
manualClientBasePath: z.boolean().optional(),
middlewarePrefetch: z.enum(['strict', 'flexible']).optional(),
mergeCssChunks: z.boolean().optional(),
navigationRAF: z.boolean().optional(),
nextScriptWorkers: z.boolean().optional(),
// The critter option is unknown, use z.any() here
Expand Down
6 changes: 6 additions & 0 deletions packages/next/src/server/config-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ export interface ExperimentalConfig {
swrDelta?: SwrDelta
middlewarePrefetch?: 'strict' | 'flexible'
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
*/
Expand Down Expand Up @@ -904,6 +909,7 @@ export const defaultConfig: NextConfig = {
missingSuspenseWithCSRBailout: true,
optimizeServerReact: false,
useEarlyImport: false,
mergeCssChunks: true,
},
}

Expand Down

0 comments on commit 9529a87

Please sign in to comment.