How to get Webpack bundle stats?


#1

Hi there!

I’m wondering how we can get Webpack bundle stats in order to check which imports and Node modules contribute more to the bundle size, using the Webpack Visualizer or any similar GUI.

This should be as easy as running webpack --json > stats.json, but I don’t know how make this work with @ionic/app-scripts.

I’ve tried adding a custom script in my package.json like this:

  "scripts": {
    "stats": "webpack --json > stats.json"
  },

But it complains about not finding the config. I’ve also tried the following but there must be something wrong as it just fails with an ELIFECYCLE error:

  "scripts": {
    "stats": "webpack --config ./node_modules/@ionic/app-scripts/config/webpack.config.js --json > stats.json"
  },

Any help will be greatly appreciated!

Thanks.


#2

+1
need help !!!