nuxt / icon

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

Using nuxt-icon in a custom module #146

Open avxkim opened 3 months ago

avxkim commented 3 months ago

module.ts

installModule('nuxt-icon', {
  size: '24px',
})

But inlineOptions doesn't work, when i'm enabling this module inside a custom module.

Atinux commented 3 months ago

You can use nuxt.options.icon.size = '24px @avxkim

avxkim commented 3 months ago

@Atinux then i have to use useRuntimeConfig() in a component?

avxkim commented 3 months ago

i did this way:

module.ts

    nuxt.options.runtimeConfig.public.iconSize =
      options.iconSize

then in a component

const config = useRuntimeConfig()

const iconSize = computed(
  () => props.size || config.public.iconSize
)

is that ok?

Atinux commented 3 months ago

Oh my bad I just saw that we are using the app.config.ts for the configuration.

Could you try with nuxt.options.appConfig.icon.size = '24px' ?

avxkim commented 3 months ago

Cannot start nuxt: Cannot set properties of undefined (setting 'size')

avxkim commented 3 months ago

@Atinux is doing this

nuxt.options.runtimeConfig.public.iconSize =
      options.iconSize

considerd as a bad practice?

Atinux commented 3 months ago

You can do this yes