codefeathers / rollup-plugin-svelte-svg

Import SVG files as Svelte Components
MIT License
75 stars 13 forks source link

Support dynamic import #14

Open eriandev opened 3 years ago

eriandev commented 3 years ago

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}/>
vish01 commented 3 years ago

Any updates on this yet?