nuxt / icon

The <Icon> component, supporting Iconify, Emojis and custom components.
https://stackblitz.com/edit/nuxt-icon-playground?file=app.vue
MIT License
868 stars 37 forks source link

[Feature Request]: SVG folder for offline mode and custom SVGs #131

Closed dany68 closed 2 months ago

dany68 commented 6 months ago

Hi

I would like to know if some contributors might be interested in a change of the api. I would be happy to help.

The idea is to load icons from an SVG folder inside the assets folder. To achieve this, there is a need to implement an npm command, such as npm run icon:prepare, that will download the used icons from Iconify during the deployment script or before pushing to the git repository.

The main advantages are:

Atinux commented 6 months ago

Thank you for the feature request @dany68

This may bring some limitations:

dany68 commented 6 months ago

What about holding a list of icons in an icons.config.ts file at the nuxt root folder ? All those icons will be downloaded as svg in the assets/icons folder. When using the component it will import the svg markup server side. If the icon is not in the config list, it will fallback to the default behavior using the Iconify API.

Additionally we can make the following cmds:

I would like to use this package for my projects but the fact that it needs to fetch on iconify client side is a blocking point. I think this approach can let the flexibility and improve performance for most apps.

alexcroox commented 5 months ago

Downloading the referenced icons in user code at build time would really improve the experience with iconify. It was a big gotcha for me not realising that icons are loaded from the network in production and that I can’t build offline apps with nuxt-icon.

Rednas83 commented 3 months ago

I would love this feature too. Why not render the required icons directly from nuxt.config.ts

Something like: icons: ["uil:github"]

formkit/icons seems to be doing something similar with a more limited set of icons.

Atinux commented 3 months ago

We are in discussion with Anthony to remake this module to support all different solutions, we will keep you posted.

adinvadim commented 2 months ago

I created module for working with local icons (color and monotone) with nuxt-icon or any iconify module. https://github.com/adinvadim/nuxt-local-iconify

Atinux commented 2 months ago

cc @antfu what do you think to support local in your new iteration based on @adinvadim work?