How to add NPM added assets to Filament.
I'm getting a little lost in the docs on this one.
I'm looking to integrate https://swiperjs.com/ into a project and want to include the sources (js/css) in my project using NPM.
$ npm install swiper
Could anyone point me in the right direction as to what to do next to ensure the proper imports happen when the field is loaded?
How do I access the assets added using NPM in my field and then how/where do I import?
Swiper
Swiper - The Most Modern Mobile Touch Slider
Swiper is the most modern free mobile touch slider with hardware accelerated transitions and amazing native behavior.
3 Replies
I think I'm making progress: https://filamentphp.com/docs/3.x/support/assets#overview
I also see I need to add artisan filament:assets to my workflow.
Is this reasonable to have in my service provider?
The files seem to be loading properly now using:
This doesn't really add them to my build process though, or is this how filament assets are supposed to work?
I feel like I'm missing a core thing here. I'm hoping it's only my implementation I need to debug from here, not getting the assets included properly. Something about including the .min.js files feels off though. A little more progress. It looks like i cannot lazy-load them when I include the field conditionally using livewire. I guess the scripts don't get loaded? I don't like the idea of loading it everywhere, but this works for the time being.
I feel like I'm missing a core thing here. I'm hoping it's only my implementation I need to debug from here, not getting the assets included properly. Something about including the .min.js files feels off though. A little more progress. It looks like i cannot lazy-load them when I include the field conditionally using livewire. I guess the scripts don't get loaded? I don't like the idea of loading it everywhere, but this works for the time being.
You need to create a custom theme:
https://filamentphp.com/docs/3.x/panels/themes