I recently moved from Docker Desktop to Rancher Desktop. However, once I did that, Vite hot reload functionality stopped working on my Laravel Sail project.
After further investigation I figured Rancher Desktop requires Vite to use Polling.
When using polling, hot reload started to work but it takes 15 to 20 seconds to react on a file change.
I figured the solution with Rancher Desktop settings.
Make sure your vite.config.js is set to use Polling:
export default defineConfig({
server: {
watch: {
usePolling: true,
},
},
})
In Rancher Desktop go to Preferences -> Virtual Machine -> Emulation and select VZ
Than go to Preferences -> Virtual Machine -> Volumes and select virtiofs
This way the Hot Reload works as expected. However, note that usePolling leads to high CPU utilization.