How to import assets in v-html with Vite

Viewed 454

I just migrated my Vue 3 app from Webpack to Vite and I'm having an issue with the require statements that I had in my templates. From what I managed to find our that is valid syntax for Webpack but not for Vite but I couldn't find out what's 1-on-1 equivalent.

More precisely for icons I had something like this:

<div
 class="icon"
 v-html="require(`../assets/icons/${name}.svg`)"
/>

And like this (if I wanted to use an external link)

<div
  class="icon"
  v-html="require(src)"
/>

What would be the Vite equivalent for the require in those v-html?

Vue v.3.2.31 Vite v.2.8.4

0 Answers
Related