Fix writing stats to the file
Dan committed
Dec 24, 2017 at 01:44 UTC
251193d4fcaa6cd28aeb4566129705ef9c8dcb5e
1 file changed
+8
-2
scripts/rollup/build.js
+8
-2
@@ -264,13 +264,19 @@ function getPlugins(
264
// Record bundle size.
265
sizes({
266
getSize: (size, gzip) => {
267
- Stats.currentBuildResults.bundleSizes.push({
267
+ const currentSizes = Stats.currentBuildResults.bundleSizes;
268
+ const recordIndex = currentSizes.findIndex(
269
+ record =>
270
+ record.filename === filename && record.bundleType === bundleType
271
+ );
272
+ const index = recordIndex !== -1 ? recordIndex : currentSizes.length;
273
+ currentSizes[index] = {
274
filename,
275
bundleType,
276
packageName,
277
size,
278
gzip,
273
- });
279
+ };
280
},
281
}),
282
].filter(Boolean);