From 91caffc4e1eced6e7e13e09a93ef4719c1e48a63 Mon Sep 17 00:00:00 2001 From: Steve Repsher Date: Fri, 31 Mar 2023 12:49:25 -0400 Subject: [PATCH] Improve bundle chunk hashes and names (#15991) --- build-scripts/webpack.cjs | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/build-scripts/webpack.cjs b/build-scripts/webpack.cjs index 7a6e943a72..fc0ce85cb6 100644 --- a/build-scripts/webpack.cjs +++ b/build-scripts/webpack.cjs @@ -152,14 +152,17 @@ const createWebpackConfig = ({ }, }, output: { - filename: ({ chunk }) => { - if (!isProdBuild || isStatsBuild || dontHash.has(chunk.name)) { - return `${chunk.name}.js`; - } - return `${chunk.name}.${chunk.hash.substr(0, 8)}.js`; - }, + filename: ({ chunk }) => + !isProdBuild || isStatsBuild || dontHash.has(chunk.name) + ? "[name].js" + : "[name]-[contenthash].js", chunkFilename: - isProdBuild && !isStatsBuild ? "[chunkhash:8].js" : "[id].chunk.js", + isProdBuild && !isStatsBuild ? "[id]-[contenthash].js" : "[name].js", + assetModuleFilename: + isProdBuild && !isStatsBuild ? "[id]-[contenthash][ext]" : "[id][ext]", + hashFunction: "xxhash64", + hashDigest: "base64url", + hashDigestLength: 11, // full length of 64 bit base64url path: outputPath, publicPath, // To silence warning in worker plugin