jpkleemans / vite-svg-loader

Vite plugin to load SVG files as Vue components
MIT License
554 stars 58 forks source link

Can we make `?component` configurable? #99

Open gkatsanos opened 1 year ago

gkatsanos commented 1 year ago

We were wondering if you'd accept a PR or had an idea if its possible to make ?component configurable? We're migrating away from https://github.com/nuxt-community/svg-module#vue-svg-loader which uses the ?inline url query option to do the same behavior and as other applications depend on the same component library we would like to try to keep it backwards compatible. We're happy to make the PR. (does this belong here or is this a behavior defined in https://github.com/svg/svgo ?

PS: I thought that using any other value besides raw or url will by default set behavior to be component but unfortunately that doesn't seem to be the case.

  vite: {
    plugins: [
      svgLoader({
        defaultImport: "component", // or 'raw'
      }),
    ],
  }

import PopupMenuAccountIcon from '@visable-dev/styleguide/dist/images/icons/account.svg ( component, works) import PopupMenuAccountIcon from '@visable-dev/styleguide/dist/images/icons/account.svg?inline' (doesn't work)

gkatsanos commented 1 year ago

@jpkleemans granted me maintainer rights, I'll do a PR for this one.