7

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?

Jheems
  • 300
  • 1
  • 4
  • 11

5 Answers5

5

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') }}" >
Abdulla Nilam
  • 36,589
  • 17
  • 64
  • 85
0

You could try also run command:

npm run build

That also will reload everything in Vite config.

kalview
  • 135
  • 2
  • 13
0

The answer is here: https://stackoverflow.com/questions/73502963/larave-vite-vite-manifest-missing-odd-files

Need to add this in vite.config.js:

build: {
    assetsInlineLimit: 0
}
0

I just had the same issue.

It was about read permissions on the images folder, as the web server was not permitted to access and read it.

madbob
  • 456
  • 1
  • 6
  • 13
0

I had the same problem, but I could solve it, deleting the file public/hot.

These steps I followed:

  1. Set my image <img src="{{ Vite::asset('resources/img/image.png') }}" alt="image">
  2. Add Vite alias in config/app.php file: 'Vite' => \Illuminate\Support\Facades\Vite::class,
  3. Clear cached config php artisan config:clear
  4. Run command npm run dev (This creates public/hot file).
  5. Delete file public/hot.
  6. Run command npm run build.
anayarojo
  • 1,121
  • 2
  • 19
  • 27