Is it no longer possible to call Vite in the Panel Providers asset method?
I was getting an exception when a fresh install runs
@php artisan package:discover --ansi
I see the examples in the docs are using resource_path
but I'm using SASS
I can fix the issue by using ! app()->runningInConsole()
but that feels really wrong.
My gut tells me this is an issue with the app ( laravel Shift from 10 -11 ) and something's wonkey.38 Replies
Run
npm run build
Laravel throws an error if there isn’t a manifest file. But it was the same on 10, not sure why you’d be seeing it now.@awcodes on a fresh install you'd run composer install, then npm install + build.
I can totally run it first but I'd have to build, then composer install, then build again so tha tthe tailwind classes are loaded.
It feels wrong.
Install shouldn’t require it.
I had another issue with a provider that worked fine in 10 and expected a DB table to be created on autoload.
But that won’t affect the composer install.
The dependencies will still install.
Then do an ‘npm’ install and run a build.
There’s a lot of sources on Google for this.
But I agree that laravel shouldn’t throw a 500 for it. It should fail gracefully. I’d rather my site be unstyled than not load at all.
I have never had this problem though.
Even in Forge. new app, add repo. and the default deployment script works fine.
for this one I had to move the node portion before composer.
Yea, it’s weird.
it feels like I fixed a the outcome to a problem, but not the cause
Could probably just run composer update instead of install. It’ll do the same thing. Haven’t come across a great solution though.
I tried to diff a fresh install with my app but the app is 50+ models and resources it's not ideal 😂
Could always do a local build and manually upload the files from public for the initial install. That would at least keep it from erroring during the initial setup.
yea
this was my solution
It’s a weird chicken and egg thing. That I would expect laravel to handle better. Especially since it’s recommended to ignore assets in the repo.
well it all works fine in Laravel 10, but our setup in Laravel 10 with Filament 2 was a bit different
Yea. I would recommend a custom filament theme for this, but yea that would be a problem with scss.
Hard to say without seeing the whole app, but something about this feels off to me though.
yea, I can't easily share the app unless I were to zip and email off Discord
No worries. Was really more a statement.
for sure
oh, and the CI pipelines borke
But the theming approach did change between v2 and v3 so it could just be a matter of handling the includes in a different way. Like with a renderHook for the panel.
I could be misunderstanding though. That you were on v3 on laravel 10 too.
I was on Laravel 10 and Filmanet 2, I wante to update to Filament 3 but it wasn't working so I went with Laravel 11 + Filament 3
10 + 2 work as expected. 11 + 3 works as expected if assets and migrations already exist.
the last part is why I feel like something else is wrong.
Ah. Yea. Could just be a matter of loading the assets differently instead of registering them directly in a service provider.
The whole theming approach was changed with v3. Check out the docs for themes at https://filamentphp.com/docs/3.x/panels/themes
For instance you could load the assets using Vite with a renderHook which means it would only ever be run when the view is loaded so you wouldn’t have to worry about it in the console.
Did you use the filament upgrade script?
humm, like making a script blade file and loading that
I did yes
No. You’re using panels, correct?
I am yes
I don't think this will help much https://gist.github.com/adampatterson/b594c7eee3c0c6e36fb0c88cc1467f57
You can use $panel->renderHook() to include the @vite directive directly on the layout in the views.
Just an option though.
yea I'll see how it goes. this is working but my spidy sens is still tingling
It doesn't make sens why the dump-autoload is bothering to look at panel assets.
Multiple vote directives won’t necessarily hurt anything but they can have unnecessary requests in the browser.
this app's got a lot of beef behind it so it should be ok
Agree 100%, but it’s a laravel issue and not something that filament can handle.
If you call the Vite facade anywhere in your app it’s going to try to load the manifest which is going to cause that error on install.
totally, I guess maybe if I can confirm, that the admin panel is only to be registered in the bootstrap/providers.php file and there's nothign else I'm missing?
Nah, it’s not going to matter where you do it. It’s the Vite facade
hummmmm
OK
good to know
maybe this is a laravel 11 thing then
Calling Vite::asset() will always look for a manifest and if it doesn’t exist it will error.
thanks for the help!