Skip to content

Instantly share code, notes, and snippets.

@GitaiQAQ
Created September 3, 2020 05:28
Show Gist options
  • Select an option

  • Save GitaiQAQ/d7d06ae80567f9b051b260b6ea2d8319 to your computer and use it in GitHub Desktop.

Select an option

Save GitaiQAQ/d7d06ae80567f9b051b260b6ea2d8319 to your computer and use it in GitHub Desktop.
import byteSize from 'byte-size';
const manifest = [];
process.on('beforeExit', () => {
console.table(manifest);
});
export default () => ({
name: 'Size',
generateBundle(_, bundles) {
Object.entries(bundles).forEach(([key, bundle]) => {
if (bundle.code) {
manifest.push([key, '' + byteSize(bundle.code.length, {
units: 'iec',
})]);
} else if (bundle.source) {
manifest.push([key, '' + byteSize(bundle.source.length, {
units: 'iec',
})]);
}
});
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment