I'm using the inline-react-svg
plugin with babel in order to import inline SVG in NextJS.
That's my .babelrc
file
{
"presets": ["next/babel"],
"plugins": [
"inline-react-svg",
[
"import", {
"libraryName": "antd",
"style": true
}
]
]
}
And also, I had to declare the modules related to image extensions because I'm using TypeScript.
That's the modules declared inside the @types
folder in the root of the project
declare module '*.png'
declare module '*.jpg'
declare module '*.jpeg'
declare module '*.gif'
declare module '*.svg'
But I'm not able to import any SVG file because TypeScript can't find the module.
Doesn't work with absolute imports but it works with the relative path "../../public/images/icons/go-back-arrow.svg"