Laravel 9 - Vite is not bundling my images even if I declared the entry point

Viewed 126

I am using Laravel 9.27.0

I am trying to reference an image directly on my master.blade.php located on resources/views. This image is being used as the favicon for the site I am working on. According to the documentation, I should be able to reference this image with Vite by adding the following to my app.js

import.meta.glob([
  '../images/**'
]);

And I should be referencing the image in my blade using this code.

{{ Vite::asset('resources/images/favicon.png') }}

However I kept getting Unable to locate file in Vite manifest: resources/images/favicon.png.

Am I misunderstanding this or am I doing something wrong?

3 Answers

You could try also run command:

npm run build

That also will reload everything in Vite config.

You have to follow this:

https://laravel.com/docs/9.x/vite#working-with-blade-and-routes,

In resources/js/app.js you have to add

import.meta.glob([ '../images/**', ]);

and also in your config/app.php have facade alias defined:

'Vite' => \Illuminate\Support\Facades\Vite::class,

then you can use

<img src="{{ Vite::asset('resources/images/photo.jpg') }}" >
Related