Skip to content
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

Custom collections aren't recognised #252

Open
adjabaev opened this issue Sep 9, 2024 · 1 comment
Open

Custom collections aren't recognised #252

adjabaev opened this issue Sep 9, 2024 · 1 comment

Comments

@adjabaev
Copy link

adjabaev commented Sep 9, 2024

Hi, hope you're all doing well!

I ran into an issue using @nuxt/ui which now uses @nuxt/icon under the hood (used to work when icon collection names could be specified as nuxt/ui module args even tho i had to add a ts-ignore as it wasn't referenced in the enum type), I am using a custom iconify collection i built which goes by

"@iconify-json/as": "npm:@my-org-name/my-icon-collection@^0.0.2",

in my package.json which isn't referenced in
https://github.com/nuxt/icon/blob/main/src/collection-names.ts
thus making it uncompatible with @nuxt/icon.
I think the issue comes from the usage of collectionNames there (as it seems we only values are only read if they are part of the underlying array):

icon/src/collections.ts

Lines 72 to 73 in cc14fe4

? collectionNames
: collectionNames.filter(collection => isPackageExists('@iconify-json/' + collection))

Would it be possible further expand the compatibility to include custom collections? (and eventually check if these are installed print an error on the logger if it isn't the case)

NOTE: It seems to work when using this configuration (note SSR isn't set to false which is a constraint I have)

icon: {
  serverBundle: {
    collections: [
      'as'
    ]
  }
}

but it the specific project is using this piece of config

[...]
ssr: false, // SSR forced to false
icon: {
  provider: 'server', // Tried with and without this
  serverBundle: {
    collections: [
      'as'
    ]
  }
}

Sorry if it is a bit long, I tried my best to keep it pleasant to read though. Thank you in advance! :)

@adjabaev adjabaev changed the title Custom collections do not work Custom collections aren't recognised Sep 9, 2024
@antfu
Copy link
Member

antfu commented Sep 10, 2024

Yeah I think that are the ways to use it. When ssr: false and provider is not set to server, the client will go to Iconify's API endpoint to ask for icons, which they don't have your custom iconset. The only way seems to serve it from your own server

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants