In Laravel Nova, how to include additional css files?
I have tried following, but gives an error.
class NovaServiceProvider extends NovaApplicationServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
parent::boot();
Nova::style('admin', asset('css/admin.css'));
}
...
}
Under public/css
folder I have admin.css
file.
Error:
file_get_contents(http://localhost:8099/css/admin.css): failed to open stream: Cannot assign requested address {"exception":"[object] (ErrorException(code: 0): file_get_contents(http://localhost:8099/css/admin.css): failed to open stream: Cannot assign requested address at /var/www/nova/src/Http/Controllers/StyleController.php:20)
Nova::style
is used to add styles to the existing bundles. Therefor, Laravel Nova needs a direct path to the CSS file so these can be parsed. Use the function public_path
to get an absolute path to files in the public folder. This way, Nova can read the files.
Nova::style('admin', public_path('css/admin.css'));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With