Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[9.x] Add missing vite() helper #43348

Closed
wants to merge 1 commit into from
Closed

[9.x] Add missing vite() helper #43348

wants to merge 1 commit into from

Conversation

Okipa
Copy link

@Okipa Okipa commented Jul 21, 2022

Hello there,

Here is my proposal to add a vite() helper that mimic the mix() helper behavior.

We sometimes need to get a versioned file path outside of a Blade view and it feels that it missing from the framework right now, as we currently only have a Blade directive to use it.

Hello there,

Here is my proposal to add a `vite()` helper that mimic the `mix()` helper behavior.

We sometimes need to get a versioned file path outside of a Blade view and it feels that it missing from the framework right now, as we only have a Blade directive right now to use it.
@Okipa Okipa changed the title Add missing vite() helper [9.x] Add missing vite() helper Jul 21, 2022
@jessarcher jessarcher self-assigned this Jul 22, 2022
@jessarcher
Copy link
Member

Hi @Okipa, I don't think this will do what you're expecting.

The Vite class returns full <script> and <link rel="stylesheet"> HTML tags, unlike the Mix class which just returned a path. This is because a single JS entry point may also contain CSS files that need to be loaded, in addition to the Vite HMR client itself.

You would need to add a new method to the Vite class (perhaps called asset) that only returned the resolved path for the given asset, which I'd be open to, especially if the other code in the class was able to be refactored to also use that method.

Another issue is that this function would create a conflict with this popular third-party package https://laravel-vite.dev/guide/features/helpers.html#vite by @innocenzi. Would the Vite class method be enough without the helper?

Marking this as draft, but feel free to close if you don't wish to pursue it.

@jessarcher jessarcher marked this pull request as draft July 22, 2022 01:27
@ankurk91
Copy link
Contributor

#43098
https://github.com/motomedialab/laravel-vite-helper

@driesvints
Copy link
Member

Going to close this already. See the above.

@driesvints driesvints closed this Jul 22, 2022
@Okipa Okipa deleted the patch-1 branch July 22, 2022 10:45
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.

4 participants