#Slow HMR, nuxt recompiles router, fonts, plugins, and types
8 messages · Page 1 of 1 (latest)
Your issue with slow HMR (Hot Module Replacement) in Nuxt, where every save triggers recompilation of router, fonts, plugins, and types, is a known pain point, especially on certain setups. Based on the knowledge sources, here are some relevant insights and recommendations:
1. HMR Performance on Windows
If you are developing on Windows, HMR can be extremely slow (20–30 seconds or more). The Nuxt team recommends using WSL (Windows Subsystem for Linux) with a distribution like Ubuntu. This can reduce reload times to under a second and avoid multiple restarts, providing a much smoother development experience. This is a significant improvement for many users and is now officially documented by Nuxt:
Windows Users: For significantly improved HMR performance, we recommend using WSL (Windows Subsystem for Linux) with a distribution like Ubuntu. This can reduce reload times to under a second and avoid multiple restarts, providing a smoother development experience.
docs: improve HMR performance note for Windows users
2. Vite HMR Protocol and Reverse Proxy
If you are behind a reverse proxy or have custom Vite HMR settings, ensure you are not forcing the HMR protocol unless necessary. Letting Vite decide the protocol (ws/wss) based on the browser's connection can avoid protocol mismatch errors and improve reliability:
By letting vite decide the websocket protocol based on whether http or https is used in browser (default behavior), we can avoid potential protocol mismatch errors and automatic protocol upgrades by the browser.
fix(vite): don't force hmr protocol ifdevServer.httpsis disabled
3. HMR and File Watching
There are ongoing improvements in how Nuxt and Vite handle file watching and warmup, especially to avoid unnecessary recompilation and to improve startup and reload times. However, some issues may still persist, particularly on Windows or with large projects. The Nuxt team is actively working on these areas, including using faster module resolvers and optimizing warmup behavior, but there may still be edge cases where HMR is slower than expected, especially if many files are being watched or invalidated on each change.
perf(vite): start warmups after nitro build
perf(nuxt): migrate to use exsolve for module resolution
4. Fonts and Tailwind Modules
Using font modules (like @nuxt/fonts or @nuxtjs/google-fonts) and Tailwind can sometimes cause extra recompilation if their configuration or usage triggers global CSS or plugin regeneration. Make sure your font and Tailwind configurations are as minimal as possible and avoid unnecessary changes to their config files during development.
5. General Recommendations
- If you are on Windows, try switching to WSL as suggested above.
- Avoid unnecessary changes to global config files (like tailwind.config.js or nuxt.config.ts) during development, as these can trigger full reloads.
- Keep your dependencies up to date, as many HMR and performance improvements are being released regularly.
- If you have custom Vite HMR settings, try reverting to defaults to see if that improves performance.
If you are not on Windows and still experience slow HMR, the knowledge sources do not provide a definitive solution for your specific case, but the above points cover the most common causes and remedies currently documented.
If you need further help, please provide your OS and any recent changes to your project setup.
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
@wispy gale Kapa.ai is still learning and improving, please let me know how I did by reacting below.
@still whale Im not on windows, I am not changing any global files and I've updated all my dependencies.
Let me check the knowledge base for you again. One moment! :books:
Thank you for clarifying that you are not on Windows, are not changing global files, and have updated all dependencies.
Based on the knowledge sources provided, there is no explicit solution or root cause documented for slow HMR on non-Windows systems when not modifying global files and with up-to-date dependencies. Most documented HMR performance issues and their solutions are specific to Windows environments or involve global configuration changes, dependency updates, or file watching settings.
There are some general improvements and bug fixes related to HMR in recent Nuxt and Vite updates, such as more efficient template invalidation and module resolution, but the sources do not provide a targeted fix for your scenario. If you continue to experience slow HMR, it may be related to an unresolved or environment-specific issue not covered in the current documentation or issue tracker.