-
Notifications
You must be signed in to change notification settings - Fork 11.1k
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
Created vite() helper to replicate functionality of mix() helper #43098
Conversation
Can you move this to a class, because there is no way to mock your helper during test. |
fad411a
to
fc3db2a
Compare
@ankurk91 I have refactored my work to make use of the I've also written a couple of tests for this. |
All looks good to me, since you are using existing class now. One more feedback, Laravel team does not like the types, for example |
Replaced nullsafe with isset check Created vite() helper to replicate the functionality of the mix() helper Abstracted vite() helper method into Vite foundation class Added tests for generation of single URL path
fc3db2a
to
8bed08c
Compare
Thanks for the heads up @ankurk91 - I've reverted some of the refactors I've made :) Out of interest, why is this? Would it not be good to enforce stricter coding standards? Chris. |
This is can be answered by Laravel team :) |
Thanks for your pull request to Laravel! Unfortunately, I'm going to delay merging this code for now. To preserve our ability to adequately maintain the framework, we need to be very careful regarding the amount of code we include. If possible, please consider releasing your code as a package so that the community can still take advantage of your contributions! If you feel absolutely certain that this code corrects a bug in the framework, please "@" mention me in a follow-up comment with further explanation so that GitHub will send me a notification of your response. |
@taylorotwell thanks for your message and completely understand. However I do feel this is a quality of life improvement for the framework that resolves an issue various people will face, including myself when upgrading to Vite. In terms of addition to the code, there is very little baggage, if any and is mostly just refactors of existing code to enhance its usefulness. I hope you'll reconsider! |
For those interested, I have created a Vite helper plugin for the time being
Hopefully this PR will be reconsidered one day :) |
I faced the same issue #42785 (comment) and I think this is a very helpful change |
Thanks @tabuna . For now I hope the package is of use 👍 Chris. |
Hey folks, just a heads up that all build mode generated URLs with the framework implementation are prefixed with the So you can host your assets in S3 for production and link to the via an absolute URL as needed. |
Thanks @timacdonald although this issue solved the fact we don't know exactly what the compiled assets URL is going to be. The merge request and plugin I've made use the asset helper so won't have any problems dealing with assets on S3 etc |
For my project, I was using the
mix()
helper function in various areas to load the absolute path to compiled mix assets.With the addition of Vite (which is awesome!), there is no such helper to retrieve absolute file paths, only strings bundled with style & script tags.
This helper allows a user to retrieve an absolute path to a Vite asset, either in hot reload or built asset mode.
Example:
@vite('resources/css/app.scss')
results in a compiled HTML tag -whereas
{{ vite('resources/css/app.scss') }}
results in an absolute file path -I hope you'll see this as a useful contribution to Laravel! I'd be happy to write up some documentation on this addition.