Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find out the size of the included packages with webpack or NPM?

Tags:

npm

webpack

I attempted using the webpack-bundle-size-analyzer package but it doesn't seem to work. Is there an easy way to output the sizes of the included packages in a webpack project?

Alternatively if there's a way to output the size of package.json packages with NPM that would be cool as well.

like image 845
Nick ONeill Avatar asked Jan 10 '16 00:01

Nick ONeill


2 Answers

Have you tried to put the run script inside package.json? It worked after I put it inside package.json like so:

...
"scripts": {
 ...
 "analyzer": "webpack --json | webpack-bundle-size-analyzer"
}
...

then in the shell do npm run analyzer

like image 107
manni Avatar answered Nov 12 '22 09:11

manni


If you need to investigate the size of packages individually, you can use this tool - https://cost-of-modules.herokuapp.com

It'll tell you what the peformance characteristics (min, min +gzipped) of any npm package would be if you were to add it to your bundle.

like image 35
Shubham Kanodia Avatar answered Nov 12 '22 10:11

Shubham Kanodia