rollup-plugin-svelte-svg icon indicating copy to clipboard operation
rollup-plugin-svelte-svg copied to clipboard

Support dynamic import

Open eriandev opened this issue 4 years ago • 1 comments
trafficstars

To be able to import it in a dynamic way in order to get the name of the icon to be imported through a prop, something like this:

<script>
  import { onMount } from 'svelte'

  export let name
  let SVGComponent

  onMount(async () => {
    const SVG = await import(`@assets/icons/${name}.svg`)
    SVGComponent = SVG
  })
</script>

<svelte:component this={SVGComponent}/>

eriandev avatar Nov 25 '20 23:11 eriandev

Any updates on this yet?

vish01 avatar Apr 16 '21 20:04 vish01