Replies: 7 comments 20 replies
-
I'd love to contribute this myself too. Let me know if there's a reason to NOT open a PR for this. |
Beta Was this translation helpful? Give feedback.
-
This is a must IMO - or some other native solution to inlining SVGs if SVGR is deemed too big. Whatever the solution is and as much as I appreciate the work they do, declaring "*.svg" in the global.d.ts as StaticImageData was far from a good choice by the Vercel team. |
Beta Was this translation helpful? Give feedback.
-
Another important aspect that a friend made me aware of. Without internalizing SVGR, there's no way to advertise that the CRA codemod will finish migrating to Next.js if its feature set is in use. |
Beta Was this translation helpful? Give feedback.
-
#26281 was merged into |
Beta Was this translation helpful? Give feedback.
-
I 100% agree we should bake this into core! |
Beta Was this translation helpful? Give feedback.
-
The SVGR package doesn't seem very well maintained. Several issues and peer-reviewed PRs that fix problems with Webpack 5 compatibility and the 5 high severity vulnerabilities that NPM currently reports with SVGR seem to be ignored by the maintainers. Another thing to take into consideration would be how to go about custom configuration. It's very common to have a separate config targeting The core concept would be a very welcome addition to Next.js, though. I think it also fits perfectly with its |
Beta Was this translation helpful? Give feedback.
-
If SVGR doesn't get integrated into Next, what is the recommended way to handle favicons? Do we somehow run that through |
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.
-
Edited
It's currently trivial to integrate SVGR thanks to #26281; however, we still lose out on the ability to choose to use an SVG with next-images OR SVGR. We get one or the other, but not both.
I believe Next should incorporate SVGR (or at least the ability to do a named import of an SVG and have it be a component) as either a plugin or the core webpack package. This would enable the prime SVGR feature without sacrificing the ability to use SVGs with next-image.
SVGR has long supported the ability to peacefully coexist with file-loader and url-loader usages by using named imports. So, there exists a way to integrate this without a breaking change and in keeping with standard practice (from both SVGR's "API" and Next's).
This is how this issue was opened initially
Describe the feature you'd like to request
I would like the ability to import SVGs and use them directly as components. This is useful for iconography and complex SVG animations, because the SVG will end up as a React component somehow, someway anyways.
Describe the solution you'd like
Integrate SVGR directly into Next.js's webpack configuration and support the ability to import an SVG directly as a component and update the type definitions for
'*.svg'
imports.SVGR has long supported the ability to peacefully coexist with file-loader and url-loader usages by using named imports. So, there exists a way to integrate this without a breaking change and in keeping with standard practice.
Describe alternatives you've considered
Today, I'm able to use https://github.com/newhighsco/next-plugin-svgr (and there many other simple ways to customize the webpack configuration to leverage the tool. You're able to now, but then you won't be able to use SVGs in next/image.
Beta Was this translation helpful? Give feedback.
All reactions