Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel Blade Hot Refresh With Vite not working

Tags:

laravel

vite

I have a fresh Laravel 9 installed. I have run npm install, included @vite(['resources/css/app.css', 'resources/js/app.js']) in the head tag, and started the vite server but when I change something in the welcome.blade.php the page doesn't refresh and I'm not getting any errors. I've checked out the documentation but I haven't noticed missing anything.

Vite config file

import { defineConfig } from 'vite';
import laravel from 'laravel-vite-plugin';

export default defineConfig({
    plugins: [
        laravel({
            input: ['resources/css/app.css', 'resources/js/app.js'],
            refresh: true,
        }),
    ],
});
like image 846
Alphy Gacheru Avatar asked Nov 15 '25 12:11

Alphy Gacheru


1 Answers

I just ran into the same issue and it turns out the welcome.blade.php file does not have the @vite(...) directive.

If you change a blade file that uses the layout files (guest.blade.php or app.blade.php), which have the @vite(...) directive, then the change will be reflected in the browser once the file is saved.

(Thank you to Billion Shiferaw for his comment above which steered me in the right direction.)

like image 100
Kasia Szymanska Avatar answered Nov 18 '25 12:11

Kasia Szymanska



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!