Angular 6 build with --stats-json not generating stats.json file

Jamshed picture Jamshed · Nov 4, 2019 · Viewed 8.8k times · Source

I'm trying to generate the stats.json file for my Angular 6 application. Below things I've already tried, but the file is not getting generated at all. My system requires to have "npm run" before every angular cli command.

  1. I've ran "npm run ng build --prod --stats-json" as well as "npm run ng build --prod --stats-json=true".

  2. I've ran "npm run ng build --stats-json" as well as "npm run ng build --stats-json=true" (without the build command).

  3. Used "npm run ng build --statsJson=true" by taking reference from cli documentation.

But still stats.json file is not being generated, which I want to read using webpack bundle analyzer. Any help, suggestion or correction in this regard is welcome.

Below are the scripts in my package.json.

"scripts": {

"ng": "ng",
"start": "ng serve",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e",
"gulp": "gulp",
"bundle-report": "webpack-bundle-analyzer dist/stats.json",
"stats": "webpack-bundle-analyzer dist/stats.json"

},

Answer

Ben Taliadoros picture Ben Taliadoros · May 28, 2021

I found mine was in /dist.

This means if you look to git for changes appearing, it might be ignored.