From a0873736aa0d8b6c0907e552da656d3cba2b4d9d Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Thu, 17 Jul 2025 10:30:52 +0200 Subject: [PATCH] Frontend: Filter assets-manifest to only include entrypoints (#94679) build(webpack): filter assets-manifest to only entrypoints --- scripts/webpack/webpack.prod.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/scripts/webpack/webpack.prod.js b/scripts/webpack/webpack.prod.js index c014f8b54d9..cc7882dbe05 100644 --- a/scripts/webpack/webpack.prod.js +++ b/scripts/webpack/webpack.prod.js @@ -86,6 +86,21 @@ module.exports = (env = {}) => integrity: true, integrityHashes: ['sha384', 'sha512'], publicPath: true, + // This transform filters down the assets to only include the ones that are part of the entrypoints + // this is all that the backend requires. + transform(assets, manifest) { + const entrypointAssets = Object.values(assets[manifest.options.entrypointsKey]).flatMap((entry) => [ + ...(entry.assets.js || []), + ...(entry.assets.css || []), + ]); + const filteredAssets = Object.entries(assets).filter(([assetFileName]) => + entrypointAssets.includes(assets[assetFileName].src) + ); + const result = Object.fromEntries(filteredAssets); + result[manifest.options.entrypointsKey] = assets[manifest.options.entrypointsKey]; + + return result; + }, }), new WebpackManifestPlugin({ fileName: path.join(process.cwd(), 'manifest.json'),