MaterialDesign-JS icon indicating copy to clipboard operation
MaterialDesign-JS copied to clipboard

Auto Import icons

Open KareemDa opened this issue 4 years ago • 5 comments

I'm using a bunch of MDI icons in my project.

So firstly. I've imported all icons. Now I want to reduce size of the bundle by importing only used icons. Is there any way to import them automatically ?

KareemDa avatar Oct 08 '21 10:10 KareemDa

Bump, is there any way to use dynamic imports with this library?

klausXR avatar Nov 18 '21 11:11 klausXR

We have solution coded for the new MDI website that we want to bundle and share eventually, but right now other than copying @mdi/svg to your assets folder and fetching them there is not a nice solution.

Until then there is no out of the box solution to this problem for those that need dynamic access to any icon during runtime.

Templarian avatar Nov 18 '21 16:11 Templarian

Is there an ETA or is it not a high priority one?

klausXR avatar Dec 09 '21 16:12 klausXR

@klausXR Unfortunately I haven't had a lot of free time. Our solution relies on a 3rd party IndexedDB library that is a bit heavy for those using it for simple caching icons. It's on my list of things to code, but I would rank it lower priority.

Templarian avatar Dec 09 '21 17:12 Templarian

any solution ? i tried : vue 3

vite 4

vuetify 3

const getIcon = async (iconName) => {
    return { [iconName]: icon } = await import('@mdi/js')
}

<template>
    <Suspense>
    <v-icon >

      {{ getIcon('mdiAccount') }}
    </v-icon>
</Suspense>
</template>

Error: <path> attribute d: Expected moveto path command ('M' or 'm'), "async () =\u003E {\r\n …".

samehdoush avatar Dec 23 '22 17:12 samehdoush