Glen Thompson
Glen Thompson

Reputation: 9996

Create React App - Re-load slow. Speed up options

I have a fairly big create-react-app project production build had 4 bundles (after gzip):

But for the development server file changes that cause re-loading are starting to take a long time 10-20 seconds, which is super frustrating for development.

Are there any options for improving this without ejecting? I can't seem to find much.

The only thing I have found to increase re-compile speed is to reduce the size of my node_modules using tree-shaking. But I can only go so far with this. Without just removing things that I need.

Upvotes: 4

Views: 4190

Answers (1)

Adam Berman
Adam Berman

Reputation: 794

One strategy you can use is to be selective about which bundles you compile. If you're only modifying one page or one section of your react app at a time for a while, you can set a global variable with the name of the webpack entry you're working on, then write a quick function that only builds things that are required for everything and the page/section of the app you're currently working on. You might run something like:

MY_CURRENT_ENTRY='fooPage' <whatever command you run to compile everything>

and then your config can parse the global variable and, if it exists, only build the required and referenced parts of your project.

Upvotes: 3

Related Questions