Override plugin's Javascript files without publishing?
Hello everyone ๐๐ป
I'm using some plugins, and I would like to make some modifications on some JS files.
I can publish these using filament:assets. The thing is, in the future, if I have to run that again, my modifications will be overwritten.
I was trying to replace the JS call in my AppServiceProvider, using something like:
But it doesn't overrwite, even if I set a package in the register method.
Maybe I'm looking on the wrong place, so if anyone can help me, I would appreciate it!
(I considered forking the plugins, but upgrading would be a messier work)
Solution:Jump to solution
So, the answer is quite simple:
- Put your updated file on your resources folder (/resources/js/custom/customfile.js)
- Register the asset with the package name in it in your AppServiceProvider
...
7 Replies
Solution
So, the answer is quite simple:
- Put your updated file on your resources folder (/resources/js/custom/customfile.js)
- Register the asset with the package name in it in your AppServiceProvider
Here's my example with Global Search Modal:
This way, when you publish the files with filament:assets, you get your custom JS in your public folder.
So it worked? we were just using the wrong paths?
Yes, it works perfectly, it just publishes our modified version when running filament:assets ๐
Just make sure to watch for updates in their code.
Yeah, but this beats forking the entire thing ๐
Totally get it. Just saying. ๐
Personally I would probably fork it. That gives you the control you need without unexpected bc
If you composer update right now and their views change but itโs still loading your script you wonโt know anything changed. But if you fork and merge into your fork then youโll get a merge conflict which you can mitigate before going to production.
And could even be possible that the change is worth a PR to the package itself, idk.๐คท
Just something to think about.
Yeah, thatโs what Iโm considering at the moment. These are minor changes but I think could benefit the whole plugin so I might just try to PR to the plugin core ๐