Skip to content

Exclude default Laravel directories from dev server file watcher#349

Open
natsuki-engr wants to merge 1 commit into
laravel:3.xfrom
natsuki-engr:feat/exclude-watched-directories
Open

Exclude default Laravel directories from dev server file watcher#349
natsuki-engr wants to merge 1 commit into
laravel:3.xfrom
natsuki-engr:feat/exclude-watched-directories

Conversation

@natsuki-engr
Copy link
Copy Markdown

This PR adds a default server.watch.ignored configuration that excludes Laravel directories which commonly cause unnecessary full page reloads during development:

  • bootstrap
  • database
  • storage
  • tests
  • vendor

Motivation

Multiple users have reported that Vite triggers unexpected page reloads when files change in directories like storage/framework/views or vendor (#324, #152, laravel/laravel#6500). @timacdonald outlined a preferred approach in laravel/laravel#6500 (comment) — handle this in the plugin with sensible defaults and an escape hatch.

Resolves #152
Related: #324, laravel/laravel#6500

Approach

  • A callback-based matcher checks only the top-level directory name relative to the project root, so nested paths like public/vendor are not affected.
  • If the user has explicitly configured server.watch.ignored, the plugin does not override it.
  • Directories referenced in the refresh config (e.g. storage/framework/views/**) are automatically excluded from the ignore list so they remain watched.
  • Only applied during serve, not build.

Added Tests

  • Ignores default Laravel directories during dev server
  • Does not set watch ignored during build
  • Respects user's server.watch.ignored config
  • Keeps refresh directories watched even if they overlap ignored defaults

@natsuki-engr natsuki-engr changed the title [3.x] Exclude default Laravel directories from dev server file watcher Exclude default Laravel directories from dev server file watcher Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Vite watches the vendor folder

1 participant