jpkleemans / vite-svg-loader

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

how to import multiple svg files? #16

Closed leosin closed 3 years ago

leosin commented 3 years ago

I have multiple svgs that need to import, how can I do it all at once

jpkleemans commented 3 years ago

Hi, you could create an index.js file in your SVG folder:

import Svg1 from './1.svg'
import Svg2 from './2.svg'

export default { Svg1, Svg2 }

Then you can import them like this:

import { Svg1, Svg2 } from './svg-folder'

Or all at once:

import * as svgs from './svg-folder'