Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite React TypeScript monorepo hot module reloading (HMR) not working

I have a Vite/React/Typescript/Yarn monorepo that contains two applications and some shared components. I'm having trouble getting HMR working when running vite dev.

The example repo is here: https://github.com/jakeboone02/em-hmr-test. If you run yarn && yarn start:app1, open http://localhost:3012/, then edit any of the components and save, the page will reload instead of just replacing the component in place.

The repo is a stripped down version of the actual proprietary code. I tried converting all the exports to defaults as suggested in this discussion question answer, but the page still reloads on every change.

Is there something wrong with the Vite config that is preventing HMR from working?

like image 654
Jake Boone Avatar asked Mar 04 '26 12:03

Jake Boone


1 Answers

Turns out I was using the deprecated @vitejs/plugin-react-refresh instead of the newer, shinier @vitejs/plugin-react. Repo has been updated.

like image 185
Jake Boone Avatar answered Mar 07 '26 06:03

Jake Boone



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!