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'),