nuxt / nuxt/icon

Problem with fetching icons (clientBundle)

Open
#376 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
1.2k
Forks
96
Avg merge
8h 12m
Merged PRs (30d)
2

Description

TLDR;
I am having problem with clientBundle working out. (I need to prefetch icons and generate CSS classes for them.)

nuxt 3.16.1
@nuxt/icon 1.11.0
doing this because apexcharts icons

I am having a problem with fetching my desired icons in advance. I am gladly using <Icon> elements, but in one case I need 5 icons in "vanilla" HTML. So I am using <span class="iconify i-pack:name"</span> element.
The problem is that this way it doesn't go through the @nuxt/icon module so the class i-pack:name doesn't exist.

Temporary fix is pasting these elements before the case:

<Icon style="display: none;" name="heroicons:magnifying-glass-plus-16-solid" />
<Icon style="display: none;" name="heroicons:magnifying-glass-minus-16-solid" />
<Icon style="display: none;" name="heroicons:arrows-pointing-out-16-solid" />
<Icon style="display: none;" name="heroicons:hand-raised-16-solid" />
<Icon style="display: none;" name="heroicons:arrow-path-16-solid" />

I would love to just use clientBundle in my Nuxt config, like this:

icon: {
  serverBundle: 'remote',
  clientBundle: {
    icons: [
      'heroicons:magnifying-glass-plus-16-solid',
      'heroicons:magnifying-glass-minus-16-solid',
      'heroicons:arrows-pointing-out-16-solid',
      'heroicons:hand-raised-16-solid',
      'heroicons:arrow-path-16-solid',
    ],
    scan: false,
  }
},

and the console writes:

ℹ Nuxt Icon client bundle consist of 5 icons with 2.41KB(uncompressed) in size

but it simply doesn't work as the temprorary solution. Maybe I have misunderstood something in the readme file of @nuxt/icons but I cannot simply find it out.
Any ideas please?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Nuxt config shown in the issue and reproduce the five-icon clientBundle setup with scan disabled. Compare the bundled icons with their use in vanilla HTML via the iconify i-pack:name classes and check the @nuxt/icon README behavior. Done means the configured icons produce usable classes outside <Icon> elements, or the limitation is documented clearly.

Written by the indexing model from the issue text.

Assessment

Tech stack
nuxt, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.