macosvitehot-reloadrancher-desktop

How to setup Rancher Desktop on macOS so that Vite server hot reload will not take ages


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.


Solution

  • 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 enter image description here

    Than go to Preferences -> Virtual Machine -> Volumes and select virtiofs enter image description here

    This way the Hot Reload works as expected. However, note that usePolling leads to high CPU utilization.