[6.x] Moves vite config into AppServiceProvider#18871
Draft
brianjhanson wants to merge 2 commits into
Draft
Conversation
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
There was a problem hiding this comment.
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
Vitesingleton inAppServiceProvider::boot()with the hot file path and build directory. - Remove per-call
clone+useHotFile/useBuildDirectoryconfiguration fromCpExtension::vite()andcraftAsset(). - Drop now-unused
CraftCms\Aliases\Aliasesimports.
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. |
Contributor
|
Cloning them is a fix for this issue: #18810 |
Contributor
Author
The clones have been restored |
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
AppServiceProviderand leave the rest alone. It seems like things are working with this, but admittedly I didn't do extensive testing.