I've created a nextjs app within my NX monorepo and I've started porting an existing NX app (within the same monorepo) to it.
My NX monorepo is set up with many alias's, all of them configured within the root tsconfig.base.json
file. For instance, I keep all my images in an images library and I load them like this from within JSX:
import myImage from '@images/myImage.png';
This is how I use the aliases from within a SCSS file:
background-image: url('@images/myImage.png');
Both of these work within my existing Non-Nextjs app, however, when I port my app over to the new Nextjs app, the aliases used within url()
are not recognized. The errors I get look like this:
Module not found: Can't resolve '../themes/@images/myImage.png'
Note, my css file lives in ./themes
and so it's treating the aliased @images/...
urls as relative paths and appending them to the current file location.
What is the recommended approach for having the aliased paths handled correctly when used within scss?