New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fails to resolve dependencies with webpack aliases #663
Comments
The same for me. Can't figure out how to make it work even with |
I have next webpack rule to handle code
And babel config
All linaria packages are Error is
|
Found here #630 the mentioning that linaria only supports module aliasing via @babel-plugin-module-resolver and webpack aliases I used |
Looks like it was fixed in #830 |
Environment
1.3.3
4.44.1
13
alpine linux (docker)
Description
I tried setting up linaria with my webpack setup and it works well for the most part.
When importing with relative paths there is no problem, however I'm using absolute imports and import aliases in my webpack project.
Reproducible Demo
In my typescript file I can successfully import relative paths:
But it fails with absolute paths:
Here is my webpack resolver configuration:
Most settings are obtained from my
tsconfig.json
file through a plugin (which linaria does not support right?).I tried setting the
roots
in the resolver to point to thesrc
directory but linaria still throws:After reading through relevant issues I added
babel-plugin-module-resolver
so my loader rules look like this:But I still get the same import error, it does not seem to change anything.
Only linaria related imports are affected. As long as the imports linaria uses are all relative other imports can still use webpack resolve logic and it works.
Ideally linaria webpack loader would be able to use the webpack config resolver (including plugins) to resolve paths the same way as webpack does. (its a webpack loader after all!)
If this breaks imports for standalone babel projects (which do not use the webpack loader but rather the babel loader) it probably means some import logic should be refactored and abstracted, but I'm not familiar with how linaria does things so I won't speculate further :P
Thanks for the help and the amazing work on linaria, it's much appreciated!
Edit:
I managed to make it work by either specifying the extension explicitly in the import or by adding relevant extensions to the config:
However IMO this is really just a workaround and a webpack loader should work with the webpack configuration out of the box using webpack resolvers.
The text was updated successfully, but these errors were encountered: