-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support loading all svgs in a folder #5
Comments
This sounds useful. It would require returning multiple components from the same
returns export default {
"tractor.svg": [green tractor component here],
"house.svg": [green house component here],
"cars/toyota.svg": [component for the toyota.svg under the cars subdirectory here]
} You would have to name the component when you register it in your
This should allow for the option of tree-shaking by importing only specific SVG components, while also allowing you to bundle everything so you can dynamically use them (e.g., |
I believe this usage is can be done easily with But looks like it not very active and have some issues:
I made it work on my local by modifying some parts for using it like that. <template>
<SvgComponent />
<component :is="components['SvgComponent']" />
</template>
<script>
import { VueComponent as components } from 'globby!./components/*.svg'
export default {
components,
setup() {
return { components }
},
}
</script> But it is little bit dirty for now. For proper solution I created an issue luxueyan/vite-transform-globby-import#5 |
Hey, first of all:
I love this plugin!!
It makes working with SVGs so much better.
Now I have a custom icon set with about 500 icons.
I'd love if I was able to get an array of all the filenames and be able to display the svgs based on the filename directly in the HTML as SVG.
Do you think something like this would be possible?
With Webpack I'd use
require.context
but with Vite I'm at a loss.Any advice much appreciated.
The text was updated successfully, but these errors were encountered: