Search code examples
javascriptnode.jsreactjsbuild

React JS - Before Dev and Build get and pass props to App


I would like to have static assets and props in my App. In the build I want to have some image assets set with a bas64 string. I think I should get those assets to the App's props on before Dev and Build. (just like you would with Gatsby.js).

So my question would be: "How to set props to the Ap pre Start and Build." Is there an out of the box solution for? Or is there an other way.


Solution

  • Default value of IMAGE_INLINE_SIZE_LIMIT is 10000 which means by default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes.

    Setting it to 0 will disable the inlining of images.

    Create file .env.production at the root of project directory and set IMAGE_INLINE_SIZE_LIMIT greater then 10000. React will convert the images to Base64 when your app starts to build.

    Note: The more you increase the IMAGE_INLINE_SIZE_LIMIT will also increase the chunk js file size

    Here you can check the Advanced Configuration