Issue
I have the following project structure
- my-project
- public
- icons
- nome.svg
- src
- components
- MyComponent
- MyComponent.module.scss
- ...
- ...
but when I try this:
backgorund-image: url('public/icon/category-qualified.svg');
the following error occurs
Module not found: Can't resolve 'public/icon/category-qualified.svg'
i add baseUrl: './src'
in my tsconfig.json
Solution
The baseUrl you are using starts from src/
, so it cannot access public
folder. You will have to go one level up with "baseUrl": "."
.
Also, I would suggest to use the full power of these imports. You can add multiple paths to use as aliases:
{
"compilerOptions": {
"baseUrl": "./",
"paths": {
"src/*": ["src/*"],
"public/*": ["public/*"]
}
}
}
Answered By - Tushar Shahi
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.