Frontend: Filter assets-manifest to only include entrypoints (#94679)
build(webpack): filter assets-manifest to only entrypoints
This commit is contained in:
@@ -86,6 +86,21 @@ module.exports = (env = {}) =>
|
|||||||
integrity: true,
|
integrity: true,
|
||||||
integrityHashes: ['sha384', 'sha512'],
|
integrityHashes: ['sha384', 'sha512'],
|
||||||
publicPath: true,
|
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({
|
new WebpackManifestPlugin({
|
||||||
fileName: path.join(process.cwd(), 'manifest.json'),
|
fileName: path.join(process.cwd(), 'manifest.json'),
|
||||||
|
|||||||
Reference in New Issue
Block a user