Extend config to support custom Vite styles and scripts - #4522
Conversation
|
BOOM! Your first PR with us, thank you so much! Someone will take a look at it shortly. Please keep in mind that:
Thank you! -- |
|
Hello @Kovah I agree with the proposed solution. I don't think there is much to do in regards to the needed Laravel version, I would just add a note on the config file with that information. If @tabacitu agrees and you add the note, for me this is ready to merge. Cheers |
|
Hat's off to you @Kovah . Flawless PR I wish all PRs we receive were like this. Including ours 😅 |
|
WHOOP-WHOOP! Congrats, your first PR on this repo has officialy been merged. You should also receive an email inviting you to the Community Members team. That's where we, commited community members, debate new features and decide what's in the Backpack roadmap. Feel free to ignore the invitation if you're not interested :-) If you want to help out the community in other ways, you can:
Again. Thank you for the PR. You are a wonderful person. Keep 'em coming :-) -- P.S. Help in the Backpack community is rewarded with free Backpack commercial licenses. It's the least we can do. If you feel you've helped the community with PRs, help & other stuff, please apply for free licenses and mention this PR. You scratch my back, I scratch your back. Thank you! |
|
Thanks for merging this! Looking forward to the release. |


WHY
BEFORE - What was wrong? What was happening before this PR?
Assets built with the new Laravel Vite setup must be added by manually overriding the
head.blade.phpandscripts.blade.phpfiles and adding the@vite()directive.AFTER - What is happening after this PR?
Users are now able to add their assets built with Vite directly in the configuration side to side with the custom Mix styles and scripts.
Side note: Vite will be the go-to way to handle asset bundling in the future, as decided by the Laravel core team. So it makes sense to provide support for it in the near future.
HOW
How did you achieve that, in technical terms?
vite_scriptsand avite_stylesoption. Both are simple arrays, currently there is no option to specify a custommanifest.jsonfile for the Vite helper so it is left out.base/inc/head.blade.phpview was extended with a block that adds the@vite()helper in the same way the currentmix_stylesare loaded.base/inc/scripts.blade.phpview was extended with a block that adds the@vite()helper in the same way the currentmix_stylesare loaded.Is it a breaking change?
I am not sure how backwards compatibility is handled in Backpack at the moment. The

@vite()helper was addded in Laravel 9.19.Adding a style or script to the config will output the directive itself without rendering, but users must upgrade to Laravel 9.19 anyway to be able to use Vite in the first place. Example with Laravel 9.10:
Is there a suggested way to handle Blade template backwards compatibility?
How can we test the before & after?
This feature can be tested by setting up Vite asset bundling as described in the Laravel docs. After installing Backpack, add a custom stylesheet or script to the new config and load the admin dashboard.