Search code examples
javascriptreactjsreduxbuildcreate-react-app

Build size 10.6 MB


I am using Create-react-app for my application. When I run npm run build, my build size is 10.6 MB. When I used source-map-explorer to analyze i got know my node modules are taking 6.3 MB and my components takes 2.84 MB, 780 KB for static and other for containers and reducers.

Kindly help me to reduce my build size. Thanks in advance


Solution

  • It's painful!

    You have multiple packages antd, material-ui, cpexcel, froala-editor ...etc These packages are awesome, but the problem is they are very large ones.

    You can have these notes to be considered for reducing the bundle size:

    1. Code-Splitting and Lazy loading..
    2. Don't import any static failes inside your app, it will be dealt with as a dependency and be included at your bundle, instead, use CDNs for your static files.
    3. Remove any un-used packages out of your package.json CLEAN IT UP.
    4. Remove any un-used import statements in your application.

    These can bring major changes to your bundle size, depending on how much you put effort on them.

    The other way might be ejecting the app, and customly set Webpack Configurations yourself to deal with the specifications of your project.