OneCompiler

How to analyze the bundle size in react

436


In this post, we will see how to analyze the bundle size of create-react-app

To do this we use the source-map-explorer package.

First, install the package.

To do so, paste the below command.

npm install -g source-map-explorer

Now open your package.json and add below script

"analyze": "source-map-explorer 'build/static/js/*.js'",

Now to generate a production build use the below command.

npm run build

Now to analyze its bundle size run below command

npm run analyze