The other day, I spent probably 15 minutes trying to figure out why the Vite::asset
helper was throwing an error saying "Unable to locate file in Vite manifest."
I looked at the manifest, and I could see my file listed there. Then I started searching online, and read a few dead-end threads on old versions of Vite and the laravel-vite-plugin
npm package.
Remember how I always say to actually read the whole error message? Well I wasn't taking my own advice.
The Blade file had Vite::asset('/resources/images/some-image.png')
but the manifest had resources/images/some-image.png
.
My eyes completely glossed over the leading slash for the absolute path in the error message. Oops!
The solution? Get rid of the leading slash.
I was kicking myself, but then I thought "Hey, that would make a good tip to share!"
Here to help,
Joel
P.S. I share embarrassing stories like this to assure you there's no shame in getting stuck.