Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Node.js, PHP and APIs

Browser does not reload when I save a Blade file under Vite

ErrorSaving a .blade.php file does not reload the browser

Short answer

Vite only reloads the page for Blade files when the Laravel plugin's refresh option is on. Set refresh to true, or list your own paths if your views live outside the defaults. If edits are not seen at all, for example in WSL2, turn on watch polling in the Vite server settings.

  • Applies to Laravel 12, laravel-vite-plugin, Vite 8, Node.js 22
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Confirm the dev server is the thing serving your page, then look at the laravel() block.

    grep -n -A6 "laravel(" vite.config.js
  2. 2Match what you see, then jump to its fix

    1. 1No refresh line inside laravel({ ... })The refresh option is not setFix
    2. 2refresh is already true, but views in a custom folder (a module or package) do not trigger a reloadYour views are outside the watched pathsFix
    3. 3Even CSS edits are not picked up while the dev server runsThe file system does not report changes (WSL2, shared folders)Fix

What does the error look like?

  • Saving a .blade.php file does not reload the browser
  • CSS and JavaScript hot update, but view changes need a manual refresh

Cause 1 of 3

The refresh option is not set

1Check

Full page reloads for server-rendered views are opt-in.

grep -n "refresh" vite.config.js

2Fix

Add refresh: true. It watches app/Livewire, app/View/Components, lang, resources/views and routes while npm run dev runs.

laravel({
    input: ['resources/css/app.css', 'resources/js/app.js'],
    refresh: true,
}),

3Verify

Restart the dev server, change a view and watch the browser reload.

npm run dev

Confirmed by laravel.com

Did this fix it?

Cause 2 of 3

Your views are outside the watched paths

1Check

Only the default directories are watched. Anything else must be listed.

ls resources/views modules 2>/dev/null

2Fix

Pass your own list of paths. This replaces the defaults, so include the default ones you still need.

laravel({
    input: ['resources/js/app.js'],
    refresh: ['resources/views/**', 'modules/**/views/**'],
}),

3Verify

Save a file in the custom folder and check the reload.

npm run dev

Confirmed by laravel.com

Did this fix it?

Cause 3 of 3

The file system does not report changes (WSL2, shared folders)

1Check

When the project sits on a file system that does not emit change events, Vite never sees the save.

pwd

2Fix

Enable polling for the watcher. It uses more CPU, so use it only where needed.

export default defineConfig({
    server: {
        watch: {
            usePolling: true,
        },
    },
    // plugins: [...]
});

3Verify

Restart the dev server and edit a file.

npm run dev

Confirmed by laravel.com

Did this fix it?

How do I stop it coming back?

  • Add any custom view folder to the refresh list the day you create it.
  • Keep refresh: true in the starter config of every Laravel project.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Back end

The AWS SDK in Node.js cannot find any credentials

Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

The AWS SDK walks a fixed credential chain: code, environment variables, the shared files in ~/.aws, then role sources such as ECS or EC2.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.