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.
Highlights
@viteRefresh()
blade directive for the purpose of adding the vite client scriptvite
helper methods that play a similar role to themix
helper methodHow to Test
Here's a sample repo of the integration working.
Steps by step
mkdir jigsaw-vite && cd jigsaw-vite
composer require tightenco/jigsaw:dev-gc/add-vite
vendor/bin/jigsaw init
npm i -D vite @tighten/jigsaw-vite-plugin
"type": "module"
to yourpackage.json
vite.config.js
package.json
and in the
postcss.config.js
should look like:source/_layouts/main.blade.php
- here we're adding the@viteRefresh
& the link + script tag, while removing themix
related codenpm run dev
- and either access it via valet atjigsaw-vite.test
or run./vendor/bin/jigsaw serve
Notes
Was initially leaning into mocking the
hotFilePath()
from theVite
class however it started to feel a little gross vs setting up thesource
proj and leaning intocreateSource(..)
. ThecreateSource
helps plays a similar role to how Laravel's Vite integration mocked the Filesystem.Though arguably now it could be strictly a few helper functions or static methods in Vite class, I do like leaning into the Container to access the Vite methods