Skip to content

Commit

Permalink
enable contenthashing in webpack 5 (#25055)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sokra authored May 12, 2021
1 parent 5f3351d commit 288984b
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions packages/next/build/webpack-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit 288984b

Please sign in to comment.