-
Notifications
You must be signed in to change notification settings - Fork 4.4k
WIP: Cleanup bad aliases and resolve config (fix #513) #516
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
Conversation
using the @ in the alias makes the import statements look they are importing a scoped module. i picked this up because I tried it with the airbnb linted which complained they were an extraneous dependency. perhaps it would be better to use a different character :) |
dismissing because of squirmy's valid concern
@squirmy Oh, that's a valid concern of course. Suggestions for a better character? Will have to try out |
How about |
How about |
Doesnt that conflict with asset paths in css-loader? |
All thing is fine. import api from '~api'
import avatar from '~components/avatar' |
I mean, in cssl loader, from the README:
|
I think @simplesmiler 's suggestion is probably the best. |
Here's some prior art: |
@squirmy Thanks! that would have thje added benefit of eslint support. Or would the eslint plugin also work without the babel one? Will have a testrun with it! |
@LinusBorg I think eslint is already happy with the current webpack alias solution. I believe this part of the config is making it work: 'settings': {
'import/resolver': {
'webpack': {
'config': 'build/webpack.base.conf.js'
}
} Was more hinting at the fact that others have done the same concept as above and used @/ as the 'alias'. I think @simplesmiler's suggestion would work well. It requires one alias, and things would be referenced like: @/file-at-root Any other aliases for further down the tree can be added by the user. :-) |
Ok then, I think that's good enough for me, will use |
Sorry that this is still unfinished, had a busy week. Hope to finish this in a quiet minute in the next days. |
- only one alias. This is secure against mismatching @nAmed as well as regular npm packages
because '@/' looks too weird imho
Changed to @, but not tested locally yet. |
Finally came around to testing this. |
Seems Also <-- NOTE: Not work -->
<img src="~assets/img.png">
<img src="@/assets/img.png"> |
|
We should probably adjust the docs a little to reflect that, even though the included aliases where never thoroughly documented in the first place. |
@LinusBorg Thanks. 👍 |
@LinusBorg |
No, it won't. The alias woeks on paths like |
OK, but maybe for the sake of readability (could be misleading for beginners), we should find another symbol. Just saying... Could provide a PR if accepted |
We're open to suggestions. As you can see in the previous comments on this PR, we discussed a few. |
My bad, I noticed the subject was brought to the table before. But still I found the @ a bit misleading. Why not |
/src
from resolve:module