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

SVG Feature generates unused SVG files in dist folder when inlining SVGs #12853

Open
1 task
sebthom opened this issue Dec 29, 2024 · 0 comments
Open
1 task
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: assets Related to the Assets feature (scope)

Comments

@sebthom
Copy link

sebthom commented Dec 29, 2024

Astro Info

Astro                    v5.1.1
Node                     v22.12.0
System                   Windows (x64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             astro-icon
                         unplugin-yaml
                         @astrojs/sitemap
                         pagefind
                         astro-runtime-config
                         @playform/compress
                         @astrojs/mdx
                         add-rel-noopener

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

No response

Describe the Bug

I am using the experimental SVG feature. Configured like this:

export default defineConfig({
  experimental: {
    svg: {
      mode: 'inline'
    }
  },
})

Then I am importing and using images like this:

---
import IconA from '../icons/icon-a.svg'
import IconB from '../icons/icon-b.svg'
---
<html lang="en">
	<head>
		<meta charset="utf-8" />
		<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
		<meta name="viewport" content="width=device-width" />
		<meta name="generator" content={Astro.generator} />
		<title>Astro</title>
	</head>
	<body>
		<h1>Astro</h1>
		<IconA /> <IconB />
	</body>
</html>

When generating the static HTML files using pnpm build I can see that the SVG images are indeed inlined in the generated HTML files but the dist/assets folder still contains now unused SVG files:

image

What's the expected result?

SVG files that are inlined shall not be generated in the dist/assets directory.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-fvh9vkpy

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 29, 2024
@ematipico ematipico added - P3: minor bug An edge case that only affects very specific usage (priority) feat: assets Related to the Assets feature (scope) labels Jan 3, 2025
@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Jan 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P3: minor bug An edge case that only affects very specific usage (priority) feat: assets Related to the Assets feature (scope)
Projects
None yet
Development

No branches or pull requests

2 participants