Skip to content

[6.x] Moves vite config into AppServiceProvider#18871

Draft
brianjhanson wants to merge 2 commits into
6.xfrom
bugfix/vite-config
Draft

[6.x] Moves vite config into AppServiceProvider#18871
brianjhanson wants to merge 2 commits into
6.xfrom
bugfix/vite-config

Conversation

@brianjhanson
Copy link
Copy Markdown
Contributor

Previously our hotFile and build directory config weren't getting picked up by the @Vite directive in app.blade.php. Most of the time things worked fine, but if you built and then started the dev server it wouldn't find the hot file and would continue serving built assets

@riasvdv maybe I missed something about why these had to be cloned and configured individually. If that's the case we can just add the lines in AppServiceProvider and leave the rest alone. It seems like things are working with this, but admittedly I didn't do extensive testing.

Previously our hotFile and build directory config weren't getting picked
up by the @Vite directive in app.blade.php. Most of the time things
worked fine, but if you built and then started the dev server it
wouldn't find the hot file and would continue serving built assets
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Moves Vite hot file and build directory configuration from individual clone-based call sites (the vite Twig function and the craftAsset helper) into the boot phase of AppServiceProvider. This ensures the @vite Blade directive in app.blade.php also picks up the correct hot file and build directory, fixing a case where the dev server's hot file was not detected after a prior build.

Changes:

  • Globally configure the Vite singleton in AppServiceProvider::boot() with the hot file path and build directory.
  • Remove per-call clone + useHotFile/useBuildDirectory configuration from CpExtension::vite() and craftAsset().
  • Drop now-unused CraftCms\Aliases\Aliases imports.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/Providers/AppServiceProvider.php Adds central Vite configuration during boot using $this->root.
src/Twig/Extensions/CpExtension.php Removes local Vite hot-file/build-directory configuration and unused Aliases import.
src/helpers.php Removes local Vite configuration in craftAsset() and unused Aliases import.

@riasvdv
Copy link
Copy Markdown
Contributor

riasvdv commented May 14, 2026

Cloning them is a fix for this issue: #18810

@brianjhanson
Copy link
Copy Markdown
Contributor Author

Cloning them is a fix for this issue: #18810

The clones have been restored

@brianjhanson brianjhanson marked this pull request as draft May 14, 2026 11:36
@brianjhanson
Copy link
Copy Markdown
Contributor Author

brianjhanson commented May 14, 2026

Moved this into a draft, I need to test it against the issue in #18810 to make sure that still works. The current state is a bit broken for me, but I'm not confident this won't just reintroduce #18810

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.

3 participants