Skip to content

[6.x]: Vite::useHotFile() called globally in ViewServiceProvider breaks host application's Vite integration #18810

@ivowk

Description

@ivowk

What happened?

Description

ViewServiceProvider::register() calls Vite::useHotFile() globally, redirecting Laravel's shared Vite singleton to the package's own hot file path (vendor/craftcms/cms/resources/hot). This overwrites the host application's hot file path (public/hot), breaking frontend Vite integration - the @Vite directive in Blade templates no longer detects the dev server, so the HMR client is never injected and Blade refresh stops working.

Steps to reproduce

  1. Configure Vite with refresh: true in vite.config.js as per the Laravel and DDEV docs
  2. Start the Vite dev server
  3. Edit a Blade template and observe the browser

Expected behavior

The host application's @Vite directive detects the dev server via public/hot and injects the HMR client, enabling full-page refresh on Blade template changes as documented by the laravel-vite-plugin.

Actual behavior

@Vite looks for the hot file at vendor/craftcms/cms/resources/hot instead of public/hot, does not detect the dev server, and falls back to the asset manifest. No HMR client is injected, Blade refresh does not work, and frontend assets may fail to load entirely if no manifest exists.

The only workaround is to manually re-override the hot file in the host app's AppServiceProvider, scoped to non-CP requests:

public function boot(): void
{
    if (!app()->runningInConsole() && !request()->isCpRequest()) {
        Vite::useHotFile(public_path('hot'));
    }
}

Craft CMS version

6.0.0-alpha.1

PHP version

8.5

Operating system and version

ddev on macOS

Database type and version

No response

Image driver and version

No response

Installed plugins and versions

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions