From 288984b1ea843465069ffa54fda048d9a745872c Mon Sep 17 00:00:00 2001 From: Tobias Koppers Date: Wed, 12 May 2021 18:33:51 +0200 Subject: [PATCH] enable contenthashing in webpack 5 (#25055) This improves long term caching by avoiding hash changes workaround fix #25013 The real problem is fixed by #24573 ## Bug - [x] Related issues linked using `fixes #number` - [ ] Integration tests added --- packages/next/build/webpack-config.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/packages/next/build/webpack-config.ts b/packages/next/build/webpack-config.ts index 966f8f23f340..9f3c72a177d2 100644 --- a/packages/next/build/webpack-config.ts +++ b/packages/next/build/webpack-config.ts @@ -902,13 +902,13 @@ export default async function getBaseWebpackConfig( isServer && isWebpack5 && !dev ? path.join(outputPath, 'chunks') : outputPath, - // On the server we don't use the chunkhash + // On the server we don't use hashes filename: isServer ? isWebpack5 && !dev ? '../[name].js' : '[name].js' : `static/chunks/${isDevFallback ? 'fallback/' : ''}[name]${ - dev ? '' : '-[chunkhash]' + dev ? '' : isWebpack5 ? '-[contenthash]' : '-[chunkhash]' }.js`, library: isServer ? undefined : '_N_E', libraryTarget: isServer ? 'commonjs2' : 'assign', @@ -1284,9 +1284,6 @@ export default async function getBaseWebpackConfig( webpackConfig.cache = cache - // @ts-ignore TODO: remove ignore when webpack 5 is stable - webpackConfig.optimization.realContentHash = false - if (process.env.NEXT_WEBPACK_LOGGING) { const logInfra = process.env.NEXT_WEBPACK_LOGGING.includes( 'infrastructure'