jpkleemans / vite-svg-loader

Vite plugin to load SVG files as Vue components
MIT License
555 stars 59 forks source link

SVG is loading is not loading as a component #57

Closed abdul-alhasany closed 2 years ago

abdul-alhasany commented 2 years ago

Hi The plugin does not seem to load the svg file as a component.

I imported svg file like this:

import ThankYou from '/images/illustrations/placeholders/thankyou.svg?component';

I also setup vite.config.ts like so:

svgLoader({
   defaultImport: 'component',
})

Despite all that I get this error:

Uncaught (in promise) DOMException: Failed to execute 'createElement' on 'Document': The tag name provided ('/images/illustrations/placeholders/thankyou.svg?component') is not a valid name

I am using version 3.4.0, which supposed to solve this issue as stated here: https://github.com/jpkleemans/vite-svg-loader/issues/51

abdul-alhasany commented 2 years ago

It was an issue because file did not exist on that path. It would be easier if an error message was displayed stating the error.

I created a pull request to show the error when the file can not be loaded.