How to integrate @svgr/webpack to make turbopack work? #50337
Replies: 5 comments 13 replies
-
There is an issue #48140 in turbopack working with @svgr/webpack, so probable need to wait for resolving this |
Beta Was this translation helpful? Give feedback.
-
Hello, is this fixed? I'm still running into the error |
Beta Was this translation helpful? Give feedback.
-
EDITThis is sorted now. I was being thick... I already had an instance of Also running into the We've got a shared UI library, and are importing a Footer component, which has SVGs inside it. This Footer component is used in multiple Next.js apps - and it works if I disable turbopack, but errors if enabled. import Facebook from '@assets/images/icons/social/facebook.svg';
import LinkedIn from '@assets/images/icons/social/linkedin.svg';
import Twitter from '@assets/images/icons/social/twitter.svg';
...
const CommonFooter = ({ children }: FooterProps) => {
const footerData = {
...
social: [
{
id: 1,
title: 'Twitter',
img: <Twitter />,
},
{
id: 2,
title: 'Facebook',
img: <Facebook />,
},
{
id: 3,
title: 'Linkedin',
img: <LinkedIn />,
},
],
};
return (
<footer>
{children}
<Container>
<nav>
{footerData.social.map((link) => (
<a
href={link.url}
target="_blank"
rel="noreferrer"
aria-label={link.title}
key={link.id}
>
{link.img}
</a>
))}
</nav>
</Container>
</footer>
);
}; I've got all the usual stuff in my Next.config.js too - including the experimental: {
turbo: {
rules: {
'*.svg': {
loaders: ['@svgr/webpack'],
as: '*.js',
},
},
},
}, |
Beta Was this translation helpful? Give feedback.
-
try this typescript
npm i @svgr/webpack |
Beta Was this translation helpful? Give feedback.
-
It might be helpful for others in the future, so just leaving this example here. Example for Next.js v15.3.0
const nextConfig: NextConfig = {
turbopack: {
rules: {
'*.svg': {
loaders: [
{
loader: '@svgr/webpack',
options: {
svgoConfig: {
plugins: [
{
name: 'preset-default',
params: {
overrides: {
// customize default plugin options
removeViewBox: false,
},
},
},
'removeDimensions',
],
},
},
},
],
as: '*.js',
},
},
},
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
The documentation says that turbopack works with @svgr/webpack, but doesn't really want to work.
next.config.js
If you run the project without turbopack, everything works fine.
Error run turbopack:
Additional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions