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

Astro glob throw unsupported files for svg #10913

Closed
Its-Just-Nans opened this issue Apr 30, 2024 · 7 comments · Fixed by #10924
Closed

Astro glob throw unsupported files for svg #10913

Its-Just-Nans opened this issue Apr 30, 2024 · 7 comments · Fixed by #10924
Labels
needs triage Issue needs to be triaged

Comments

@Its-Just-Nans
Copy link
Contributor

Its-Just-Nans commented Apr 30, 2024

Astro Info

Astro                    v4.7.0
Node                     v18.18.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none
Integrations             none

Describe the Bug

Astro glob throw unsupported files for svg

const svgs = await Astro.glob("../files/*.svg")

throws

unsupported file type: undefined

What's the expected result?

Detect and import svgs

Link to Minimal Reproducible Example

https://stackblitz.com/edit/astro-vexf1b

@github-actions github-actions bot added the needs triage Issue needs to be triaged label Apr 30, 2024
@Grohotun
Copy link

Grohotun commented Apr 30, 2024

I have almost the same error, but I do get object. But it's siblings are not having props, so even simple url to file is not working.

image

in dev mode it shows no images.

@Its-Just-Nans
Copy link
Contributor Author

@Grohotun

In fact, it's when a svg doesn't have width or height specified ;)

The PR #10924 add a clearer error message

@Grohotun
Copy link

Grohotun commented May 1, 2024

@Grohotun

In fact, it's when a svg doesn't have width or height specified ;)

The PR #10924 add a clearer error message

@Its-Just-Nans setting width & height doesn't help at all.

@Its-Just-Nans
Copy link
Contributor Author

@Grohotun

In fact, it's when a svg doesn't have width or height specified ;)

The PR #10924 add a clearer error message

@Its-Just-Nans setting width & height doesn't help at all.

Can you provide the svg ?

@Grohotun
Copy link

Grohotun commented May 1, 2024

@Grohotun
In fact, it's when a svg doesn't have width or height specified ;)
The PR #10924 add a clearer error message

@Its-Just-Nans setting width & height doesn't help at all.

Can you provide the svg ?

Sure I can but in fact is doesn't matter, which svg's to use.
If I use Image component for any one of them - it is loading properly.

@Princesseuh
Copy link
Member

Princesseuh commented May 2, 2024

The SVG in the repro is quite wonky, many tools can't parse it correctly. For instance, trying to paste it in https://jakearchibald.github.io/svgomg/ results in an error about it being invalid.

image-size, the library we use, tries its best to detect that it's a SVG, but it's tough when the SVG is malformed / unusually formed.

Replacing the SVG with a more proper one (a random leaf icon I found online) works: https://stackblitz.com/edit/astro-plbyh1?file=src%2Ffiles%2Fleaf.svg

@matthewp
Copy link
Contributor

matthewp commented May 3, 2024

Closing as this is an upstream issue.

@matthewp matthewp closed this as not planned Won't fix, can't repro, duplicate, stale May 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs triage Issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants