Description
I'm just trying to import a simple img into my gatsby application, from a path entry in my json file.
Steps to reproduce
When I'm using
<img
alt="..."
src={require("assets/images/todd-logo.svg")}
/>
The image gets imported and rendered as expected. But when I try to import the image with a variable as a path:
<img alt="..." src={require(`${props.image}`)} />
I get an error similar to:
Error: Cannot find module 'assets/images/accomodation-room1.png'
This happens even if I use assets/images/todd-logo.svg
as the variable value in the json file, in the same js file I'm working on. This problem arises when I use a variable as a path.
I have added a jsconfig.json with the following parameters to deal with paths in my project, while using the plugin 'gatsby-plugin-resolve-src'(maybe the problem it's here...?)
{
"compilerOptions": {
"baseUrl": "src",
"paths": {
"*": ["src/*"],
"assets": ["src/assets"]
}
}
}