Fix writing stats to the file

This commit is contained in:
Dan
2017-12-24 01:44:08 +00:00
parent 32797fd3a3
commit 251193d4fc
+8 -2
View File
@@ -264,13 +264,19 @@ function getPlugins(
// Record bundle size.
sizes({
getSize: (size, gzip) => {
Stats.currentBuildResults.bundleSizes.push({
const currentSizes = Stats.currentBuildResults.bundleSizes;
const recordIndex = currentSizes.findIndex(
record =>
record.filename === filename && record.bundleType === bundleType
);
const index = recordIndex !== -1 ? recordIndex : currentSizes.length;
currentSizes[index] = {
filename,
bundleType,
packageName,
size,
gzip,
});
};
},
}),
].filter(Boolean);