natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!

Home Page:https://astroicon.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unable to load local Icons when using "--experimental-static-build" flag

AndreBClark opened this issue · comments

commented

thanks for making this very useful component.
unfortunately I noticed an issue with using the package with the new experimental build flag. this may be an issue with the new build process, or something wrong with the astro-icon.
of course user error on my end is always a possibility.
let me know if there is any additional information I can provide

  • works fine without the flag, works correctly with astro dev
  • crashes build when running astro build cmd with the experimental build flag.
  • "svgo" is added to vite.ssr.external[]
  • when i click the link in the error to navigate to /src/icons/Wordmark.svg navigates to the correct SVG even though it claims to not be able to load it.
  • build completes, but servering the home page returns a 404
  • are there any specific ways i should format the svg? specific tags/layout within the svg?
  • this is the only obstacle preventing me from using the new build mode, so I will continue using the default astro build process until this is resolved.
  • just tried removing all other props height, class etc.. and error still occurs
---
import { Icon } from 'astro-icon' 
---
 <Icon name="Wordmark" height="42" class="mt-8" />

system config

  • OS: Linux amd64 Pop!_os/Ubuntu 21.10
  • Node@17.3.1
  • yarn3.1.1
  • astro@0.22.17
  • astro-icon@0.5.3

Error

01:21 AM [build] Error rendering: Error: [astro-icon] Unable to load icon "Wordmark"!
Error: [astro-icon] Unable to load "/src/icons/Wordmark.svg". Does the file exist?
    at file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:42344:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async renderToString (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1688:21)
    at async renderComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1518:20)
    at async _render (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1443:11)
    at async renderAstroComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1694:20)
    at async _render (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1453:12)
    at async renderComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1513:20)
    at async _render (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1443:11)
    at async renderAstroComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1694:20)
01:21 AM [build] Error rendering: Error: [astro-icon] Unable to load icon "Logo"!
Error: [astro-icon] Unable to load "/src/icons/Logo.svg". Does the file exist?
    at file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:42344:13
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async renderToString (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1688:21)
    at async renderComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1518:20)
    at async _render (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1443:11)
    at async renderAstroComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1694:20)
    at async renderToString (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1689:18)
    at async renderComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1518:20)
    at async _render (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1443:11)
    at async renderAstroComponent (file:///home/andreclark/Documents/GitHub/lunarium/frontend/dist/assets/Default.de3d07fa.mjs:1694:20)
commented

appears to work as expected with astro@next. Perhaps this will likely be fixed on the next release for Astro?

commented

appears to not work with astro@0.22.20 with flag.
workaround: disable --experimental-static-build flag

Sorry for the delay here! This was fixed in #26. astro-icon@0.6.0 should now work with --experimental-static-build enabled.