Search code examples
phpcsslaravelportvite

VIteJS Laravel, background-img in .css


I'm struggling to use background-image: url("/assets/back.png"); in laravel with vitejs. On the web page, the image is going to be searched on port 5173 (the one of vite) and not on port 8000, the one of Laravel, so the image is not found.

My image is in /public/assets/back.png And my css file in /resources/css/app.css

Do you have an idea of how to do it ?


Solution

  • You should try to use @/resources/images/img.png which should be converted as /images/img.png during dev process and /assets/images/img.xwv31s.png after prod build.