How to use SVG sprite with Turbopack? #84595
Unanswered
VitaliyPotapov
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Hi! I have a Next.js app with ~100 icons and I’d like to bundle them into a single SVG sprite that’s loaded once and cached by the browser.
What I’m trying to achieve
sprite.svg
(external file), so usage is<use href="/sprite.svg#icon-id" />
.I’ve read the Turbopack docs on configuring webpack-style loaders. But I want to avoid adding SVG into JS bundle (per this tweet)
What I tried
.svg
imports and return a tiny component that references the sprite:Configured via Turbopack:
But I’m hitting Turbopack limitation: there’s no plugin API to emit once after all modules and no
this.emitFile
equivalent from a loader, so I can’t reliably write a singlesprite.svg
at build time.Is there an recommended way to produce a single external SVG sprite with Turbopack?
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions