Following the Vite documentation you can use the solution mentioned and explained here: vite documentation. const imgUrl = new URL('./img.png', import.meta.url) document.getElementById('hero-img').src = imgUrl More @Wikipedia
Hover over any link to get a description of the article. Please note that search keywords are sometimes hidden within the full article and don't appear in the description or title.