Absolute paths and the Vite asset helper

Want to laugh at me? It's ok.

Joel Clermont
Joel Clermont

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,


P.S. I share embarrassing stories like this to assure you there's no shame in getting stuck.

Toss a coin in the jar if you found this helpful.
Want a tip like this in your inbox every weekday? Sign up below 👇🏼

Level up your Laravel skills!

Each 2-minute email has real-world advice you can use.