F
Filament7mo ago
adam

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
Illuminate\Foundation\ViteManifestNotFoundException
Vite manifest not found at: /opt/atlassian/pipelines/agent/build/public/build/manifest.json
Illuminate\Foundation\ViteManifestNotFoundException
Vite manifest not found at: /opt/atlassian/pipelines/agent/build/public/build/manifest.json
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
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
@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.
awcodes
awcodes7mo ago
Install shouldn’t require it.
adam
adamOP7mo ago
I had another issue with a provider that worked fine in 10 and expected a DB table to be created on autoload.
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
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.
awcodes
awcodes7mo ago
Yea, it’s weird.
adam
adamOP7mo ago
it feels like I fixed a the outcome to a problem, but not the cause
awcodes
awcodes7mo ago
Could probably just run composer update instead of install. It’ll do the same thing. Haven’t come across a great solution though.
adam
adamOP7mo ago
I tried to diff a fresh install with my app but the app is 50+ models and resources it's not ideal 😂
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
yea this was my solution
$assets = [];
if (!app()->runningInConsole()) {
$assets = [
// Styles
Assets\Css::make('dashboard-fonts', Vite::asset('resources/sass/fonts.scss')),
Assets\Css::make('dashboard-styles', Vite::asset('resources/sass/app.scss')),

// Scripts
Assets\Js::make('dashboard-scripts', Vite::asset('resources/js/app.js')),
];
}
$assets = [];
if (!app()->runningInConsole()) {
$assets = [
// Styles
Assets\Css::make('dashboard-fonts', Vite::asset('resources/sass/fonts.scss')),
Assets\Css::make('dashboard-styles', Vite::asset('resources/sass/app.scss')),

// Scripts
Assets\Js::make('dashboard-scripts', Vite::asset('resources/js/app.js')),
];
}
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
well it all works fine in Laravel 10, but our setup in Laravel 10 with Filament 2 was a bit different
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
yea, I can't easily share the app unless I were to zip and email off Discord
awcodes
awcodes7mo ago
No worries. Was really more a statement.
adam
adamOP7mo ago
for sure oh, and the CI pipelines borke
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
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.
awcodes
awcodes7mo ago
Ah. Yea. Could just be a matter of loading the assets differently instead of registering them directly in a service provider.
awcodes
awcodes7mo ago
The whole theming approach was changed with v3. Check out the docs for themes at https://filamentphp.com/docs/3.x/panels/themes
awcodes
awcodes7mo ago
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?
adam
adamOP7mo ago
humm, like making a script blade file and loading that I did yes
awcodes
awcodes7mo ago
No. You’re using panels, correct?
adam
adamOP7mo ago
I am yes
adam
adamOP7mo ago
Gist
AdminPanelProvider
AdminPanelProvider. GitHub Gist: instantly share code, notes, and snippets.
awcodes
awcodes7mo ago
You can use $panel->renderHook() to include the @vite directive directly on the layout in the views. Just an option though.
adam
adamOP7mo ago
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.
awcodes
awcodes7mo ago
Multiple vote directives won’t necessarily hurt anything but they can have unnecessary requests in the browser.
adam
adamOP7mo ago
this app's got a lot of beef behind it so it should be ok
awcodes
awcodes7mo ago
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.
adam
adamOP7mo ago
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?
awcodes
awcodes7mo ago
Nah, it’s not going to matter where you do it. It’s the Vite facade
adam
adamOP7mo ago
hummmmm OK good to know maybe this is a laravel 11 thing then
awcodes
awcodes7mo ago
Calling Vite::asset() will always look for a manifest and if it doesn’t exist it will error.
adam
adamOP7mo ago
thanks for the help!
Want results from more Discord servers?
Add your server