-
-
Notifications
You must be signed in to change notification settings - Fork 538
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
SVG Logo during build doubles in dist/_astro folder #2161
Comments
Hi @ztxone 👋 What this looks like behind the scenes is Starlight is creating a component for:
In the first case (site title) Astro is using the HTML In the second (hero) Astro is the Astro Assets With that being said, from a technical perspective, this is behaving as I would expect as they are two different logic routes from my understanding. However, maybe someone else will have some thoughts on this as I agree that in the case SVGs I would expect them to roughly be the same file and this is un-needed duplication. But this is much easier said than to have any changes put in to address this. Edit: Fixed a link to better highlight the code snippet |
I believe that is only the case when using the
(underline above added by me) However, the section on
Again, not to disagree with your point that there is duplication here as an end result, but just to say that it is working as I would expect given my personal understand. |
Asked over on Astro and @Princesseuh give a bit more input here:
However, regarding SVGs (also from @Princesseuh)
So, in theory, it may be possible to use the same method of images (i.e. both using the |
Ok, thanks for explanation. I've understood that in this case it works as it should be. |
well but there are two svgs in dist folder from 1 svg used by different methods somehow with different hashes)) |
One additional thing I dug up while testing an alternative to the current approach in Starlight is that the
So even after mocking up a test to see if it was possible to de-duplicate these it resulted in the same. I'm not sure if this is due to the virtual module causing some obfuscation that results in Astro not being able to detect they're the same file or not, or if it's a red-herring. @delucis you had #51 that added that virtual module in, do you think it could be a reason for images still being duplicated even after switching the |
Yes, but the contents (at least in my local test) are the same for both files. It's just a different file name in order to prevent any potential filename collision. |
RE: Why using a virtual module, maybe it's because when defining an image in front matter (like the case for Hero) the image helper from Zod is used which will populate the required metadata: https://docs.astro.build/en/guides/images/#images-in-content-collections. When using exclusively a config, it's only a string and not the imported image and it's respective properties that are needed by |
The virtual module shouldn’t make a difference here — that’s just needed to pass the user-configured image path to other parts of Starlight code. I think the following is happening:
We should probably use (Note though that I suspect Astro will still output the file twice in the build output for this reason) |
This is no longer accurate in |
I'll try solve this issue. |
What version of
starlight
are you using?0.25.3
What version of
astro
are you using?4.12.2
What package manager are you using?
pnpm
What operating system are you using?
Mac
What browser are you using?
Chrome
Describe the Bug
I have logo.svg in /src/assets/logo.svg
Added link to logo in astro.config.mjs
Added same logo in /src/content/docs/index.mdx
as image for hero at frontmatter
After pnpm run build i'm getting 2 versions of same logo.svg in /dist/_astro/ folder with 2 type of hashes in filename as shown on screenshot
Same stuff in reproduced stackblitz - adding logo to header through astro.config.mjs - doubles houston.webp in dist folder
Probably it is unnecessary doubling of asset or am i doing smth wrong?
Link to Minimal Reproducible Example
https://stackblitz.com/edit/github-spzcpm?file=astro.config.mjs
Participation
The text was updated successfully, but these errors were encountered: