Search code examples
angularwebpackjhipsterwebpack-bundle-analyzer

Webpack Bundle Analyzer Is Not Working For Jhipster Angular Application


I am using jhipster gateway application as a gateway for micro services.

To analyze my webpack bundle I am trying below approach

Ran npm install -g webpack-bundle-analyzer

In your Angular app, run ng build --stats-json

here I am getting an error like below

Cannot determine project or target for command.
Error: Cannot determine project or target for command.
    at BuildCommand.initialize (C:\Rk\gateway\node_modules\@angular\cli\models\architect-command.js:122:23)
    at process._tickCallback (internal/process/next_tick.js:68:7)
    at Function.Module.runMain (internal/modules/cjs/loader.js:834:11)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Solution

  • webpack-bundle-analyzer comes preconfigured for JHipster apps for the prod build. You can find its config in webpack.prod.js.

    To view the output, run npm run webpack:prod and open target/classes/stats.html (or in build instead of target for gradle)