SVG Feature generates unused SVG files in dist folder when inlining SVGs #12853
Open
Description
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:
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.