Prashant Mohite
Prashant Mohite

Reputation: 798

React Lazy Not working for Production Build

In my current project, I am using lazy for my routes. It's working perfectly on local but for the production build, it's giving me multiple issues.

When I try to redirect on one of the lazy routes it tries to access the chunk for the relative path and not the base path. something like below

https://myapp.com/mypath/static/js/1.2324dfg.js

instead of https://myapp.com/static/js/1.2324dfg.js

I am preparing the production build simply with npm run build prod command. Please let me know if I am missing any setting.

Upvotes: 6

Views: 1512

Answers (1)

asifsaho
asifsaho

Reputation: 528

Can you try putting this line in your package.json file? I had the same issue and now working fine with this setting. Good luck

"homepage": "/",

Upvotes: 5

Related Questions