Skip to content

Add embedded sprite option for animations and font-face support#2

Merged
evoactivity merged 1 commit into
mainfrom
embed-sprite-option
Apr 22, 2026
Merged

Add embedded sprite option for animations and font-face support#2
evoactivity merged 1 commit into
mainfrom
embed-sprite-option

Conversation

@evoactivity
Copy link
Copy Markdown
Contributor

Introduces an embedded plugin option that inlines named sprite sheets directly into the HTML document via Vite's transformIndexHtml hook, rather than loading them as external files.

When a sprite is loaded as an external SVG document and referenced via <use href="sprite.svg#id">, browsers prevent CSS animations (@Keyframes), SMIL animations (, ), and @font-face rules defined inside elements from affecting the referencing document. Inlining the sprite into the HTML bypasses this restriction entirely.

Introduces an `embedded` plugin option that inlines named sprite sheets
directly into the HTML document via Vite's `transformIndexHtml` hook,
rather than loading them as external files.

When a sprite is loaded as an external SVG document and referenced via
`<use href="sprite.svg#id">`, browsers prevent CSS animations
(@Keyframes), SMIL animations (<animate>, <animateMotion>), and
@font-face rules defined inside <symbol> elements from affecting the
referencing document. Inlining the sprite into the HTML bypasses this
restriction entirely.

- Add `embedded: boolean | string[]` option to SvgJarOptions
- Embedded sprites are still emitted as asset files and additionally
  injected into every HTML entry point via transformIndexHtml
- Symbols in embedded sprites use local fragment hrefs (#symbolId)
  rather than external file references
- Add 5 animated SVG fixtures to the vanilla test project covering CSS
  animations, SMIL <animate>, and SMIL <animateMotion>
- Add animations.html manual test page to the vanilla test project
- Add external asset reference fixtures (absolute image URL, @font-face
  with external font URL) and verify they pass through unchanged
- Fix bug: absolute URLs in <image href> and <use href> were being
  incorrectly resolved against the local filesystem in both the load
  and generateBundle hooks
- Add E2E tests for embedded sprite injection and animation preservation
- Update README with embedded option documentation and explanation
@evoactivity evoactivity changed the title add embedded sprite option for animations and font-face support Add embedded sprite option for animations and font-face support Apr 22, 2026
@evoactivity evoactivity added the enhancement New feature or request label Apr 22, 2026
@evoactivity
Copy link
Copy Markdown
Contributor Author

Note that this adds new svg's to the vanilla test-project, requiring the e2e test to be ran manually to update the saved screenshot.

@evoactivity evoactivity merged commit 9f2d321 into main Apr 22, 2026
8 of 9 checks passed
@github-actions github-actions Bot mentioned this pull request Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant