Closed AprilArcus closed 2 years ago
You probably need a custom join
function. Check out the advanced features docs. There are a few examples that might help.
To fall back to node_modules
you might need to rewrite the uri
to have with a ~
prefix.
Thanks, that does work. It would be nice if the resolution logic could match sass-loader
's handling of import
, in which both node_modules and aliases will be tried if the file's own directory does not contain a match.
According to this the alias should just work, but you still need the ~
to trigger webpack to resolve it. Maybe I misunderstand though. If you have a concrete example for sass-loader feel free to share so I can see how it differs.
Either way I'll mark the question as closed. Glad you got a result. 👍
As you can see here, sass-loader
no longer requires the ~
prefix, and in fact recommends against it.
Using
~
is deprecated and can be removed from your code (we recommend it), but we still support it for historical reasons. Why can you remove it? The loader will first try to resolve@import
as a relative path. If it cannot be resolved, then the loader will try to resolve@import
inside[node_modules](https://webpack.js.org/configuration/resolve/#resolvemodules)
.
Since sass-loader
specifically recommends the use of resolve-url-loader
in tandem with it, it would be great to match their behavior.
I want all URLs starting with
./
or../
to be resolved usingresolve-url-loader
, and all other URLs to be resolved relative to node_modules or my aliases. Is there a way to restrict this loader to only rewrite paths of this kind?