0

I forked (not ejected) Create React App 5 and have modified it slightly to fit my application: I change PUBLIC_URL to be file://build/ (I have an Electron app that loads a HTML file using file:// but that shouldn't make any difference).

When I do this, when I edit a file while webpack-dev-server 5 is running, webpack 5's Hot Module Replacement infinitely reloads the window instead of just reloading the window once.

I looked into the sourcecode for HMR and when the webpack-dev-server client loads it gets the current hash of the bundle, then HMR tells the client about a new hash, it then does a comparison and if it's different, it triggers either a HMR replacement or a full page reload (which happens to me because it's my src/index file).

For some reason the initial hash is never updated to the new hash so when it does the comparison it always fails, so infinitely reloads.

Why is this happening? I should be able to change PUBLIC_URL to anything with a slash at the end of it.

1 Answer 1

0

The issue was the bundle JS file was being cached by the browser so it never has a new hash for that equality check.

By default webpack-dev-server does not cache the bundle file.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.