I have the following component to dynamically import an icon from mdi/js. The only problem with this is that it doesn't do tree-shaking. Does anyone know how to make tree-shaking work with this kind of setup? I can use this anywhere like
<Icon name='mdiMagnify'>
Icon.vue
<template>
<v-icon v-bind="$attrs">{{ icon }}</v-icon>
</template>
<script>
export default {
name: 'Icon',
props: {
name: {
required: true,
type: String,
},
},
data: () => ({
icon: null,
}),
async created() {
const { [this.name]: icon } = await import('@mdi/js')
this.icon = icon
},
}
</script>
The reason behind this is, I won't be needing to import each and every icon that i need in all my components and passing it to a data variable to be able to be utilized in vue template.