Frontend: Filter assets-manifest to only include entrypoints (#94679)

build(webpack): filter assets-manifest to only entrypoints
This commit is contained in:
Jack Westbrook
2025-07-17 10:30:52 +02:00
committed by GitHub
parent ae4dc181d1
commit a0873736aa
+15
View File
@@ -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'),