Browser refresh not working in new panel
I have created a new panel in my filament app on top of my admin panel.
I have added a resource to my new panel, and it seems to work well. But I noticed that when I update my new panel resource code, the admin panel browser tabs are refreshing, but not my new panel browser tabs. So it seems I need to make an extra step to get browser refresh to work with my new panel when vite hot reloads.
I could not find anything about this in the Filament documentation, any help is much appreciated.
18 Replies
Where are the new panel resource files?
My new panel is called
Delivery
, with id: delivery
.
My resource file is in app/Filament/Delivery/Resources/GroupOrderResource.php
.Hmm, I would expect that to work. Do you have a custom theme.
Did you restart the dev server after creating the resource?
I do have a custom theme here
resources/css/filament/admin/theme.css
, maybe this is what is causing the admin panel to reload in the first place, and since the the delivery panel doesn't have a theme, no browser refresh is happening there?
Do you mean vite or the dev webserver (Herd)?Npm run dev (Vite)
Yes I have npm run dev running, and I did restart it as well
Did you add the custom theme to the new panel as well?
No I have not had a need for one yet. Would you recommend me to add one anyway?
Just seems like Vite isn’t picking up the refresh paths. And I thinking it’s because you new panel isn’t using any thing that would trigger it to reload.
You could try adding the path manually to the Vite config if it’s not going to use a custom theme.
I tried to add
->viteTheme('resources/css/filament/admin/theme.css')
to my delivery panel service provider, and now the browser refreshes. That explains it!The content key in the tailwind config tells Vite to watch those paths. 🙂
Like I said you could add the path in Vite.config.js too.
Ie
Either way though.
Currently I have:
Can I just change this to:
Yes. You just need to make sure to import and merge in refreshPaths from the laravel-vite-plugin
But I would assume you’d want the same custom theme for both panels if not another custom theme for that specific panel. But whatever you need for your app.
You could add
app/Livewire/**
there too to live reload livewire class changes too.Hmm..
When I add all this to my vite.config.js:
The browser does not refresh at all when the vite server hot reloads, when I update my resource code. Strange..
I will just add a theme to my delivery panel, as that works 😄
Hmm, I would expect it to. Weird. At least there’s a simple solution. 😆
Maybe because it still needs a @vite directive somewhere on the layout to work. 🤔
I am happy to try, but I am not sure where to add what exactly.
Just stick with the theme. It’s easy enough.
I would recommend creating a separate one for the new panel though even if they are the same, just in case there could be things in one panel that need to be different in the other.
Don’t want to change something in admin that breaks the new one stylistically by accident.
There should be a —panel flag for filament:theme command
Just give it the id of the new panel and add it your Vite inputs.
Thanks!
I will add a separate theme for the new panel 🙂