How to properly add custom js files to Filament panel.

I'm in the process of building a custom alpine component which i'm using in a specific custom page of the panel, so far so good. Everything works properly in local but when i deployed the project to production i encountered an error where the file was aggressively cached which caused the entire thing to blow up by not loading the newest version of it, the only solution i found at the time was to change the name of the script. This brought me to believe my approach to the entire thing was faulty, right now i'm including the script directly in the boot method of the custom page
\Filament\Support\Facades\FilamentAsset::register([
\Filament\Support\Assets\Js::make('taskjob-recorder', __DIR__ . '/../../resources/js/taskjob-recorder.js'),
]);
\Filament\Support\Facades\FilamentAsset::register([
\Filament\Support\Assets\Js::make('taskjob-recorder', __DIR__ . '/../../resources/js/taskjob-recorder.js'),
]);
I tried to change my approaching by registering the script into AppServiceProvider which worked, unless i called the ->loadedOnRequest method to allow the x-load-js to lazyload it in that case it never managed to register the file at the bottom of the page as the documentation says, Is there a better approach to this ? it would also help in the future to know how to include npm packages into the panel and in specific pages if possible.
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server