natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
992 stars 57 forks source link

[v1] Confusing "No icons detected!" message #176

Closed srflp closed 6 months ago

srflp commented 6 months ago

What version of astro-icon are you using?

v1.0.1

Astro Info

Astro                    v4.0.8
Node                     v20.9.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/tailwind
                         astro-icon
                         @astrojs/sitemap

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

During build or starting a dev server without collections, but with icons in src/icons folder, the message "No icons detected!" gets printed. This is quite misleading, because in my case icons from src/icons were detected and displayed correctly.

What's the expected result?

The message should be more like "No collection icons detected!"

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-mbnz9k?file=src%2Fpages%2Findex.astro

brentarias commented 6 months ago

I have the same problem, except that the icons cannot be referenced.

04:32:59 PM [astro-icon] No icons detected!
 error   Unable to locate "logos/youtube" icon!

The youtube.svg file is present. I don't know why it is not detected. My configuration:

  "dependencies": {
    "@astro-community/astro-embed-youtube": "^0.4.1",
    "@astrojs/mdx": "^1.1.3",
    "@astrojs/rss": "^2.4.3",
    "@astrojs/sitemap": "^1.3.2",
    "@sanity/astro": "2.1.1",
    "@sanity/client": "^6.4.12",
    "@sanity/image-url": "^1.0.2",
    "astro": "^3.4.0",
    "astro-icon": "^1.0.1",
    "astro-portabletext": "^0.9.6",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "sanity": "*"
  }

I am using pnpm and node 18.18.0.

I found I can solve or circumvent the problem if I explicitly configure the default path:

    icon({iconDir: "src/icons"})]

The above "fix" only works if I don't use any subfolders under "src/icons". So my reference must look like <Icon name="youtube" /> instead of <Icon name="logos/youtube" />.