Laravel falsly uses hot loading via Vite

Tobias Etzold • March 3, 2025

laravel vite

I recently encountered an issue in my development environment where a Laravel application was only loading assets correctly when Vite was running via npnpm run dev. Upon inspecting the generated code, I discovered that instead of the expected pre-built stylesheet, there was only a reference to the hot-loading portion of Vite in Laravel.

After further investigation, I found that Laravel generates this reference only when a hot file is present in the public directory. Indeed, the file was there, even though the continuous development build system (via npm) was not running. Once I deleted the file, the assets loaded correctly again.

It appears that the hot file was not removed after the npm run dev process was terminated. As a result, if you encounter a similar issue, I recommend checking for any stray hot files in the public directory of your Laravel application. Deleting this file should resolve the problem.