I would like to do imports like this import Foo from '~/components/Foo'
https://github.com/tleunen/babel-plugin-module-resolver
If I set my .babelrc
to:
{
"plugins": [
["module-resolver", {
"root": "./",
"alias": {
"~/": "./"
}
}]
]
}
I have also tried (and lots of other combinations):
{
"plugins": [
["module-resolver", {
"root": ".",
"alias": {
"~": "."
}
}]
]
}
Then I can use it in scripts like so:
import Foo from 'components/Foo'
import Foo from '~/components/Foo'
(I would expect it to)~/
so there aren't multiple usage patterns.{
"plugins": [
["module-resolver", {
"root": ["./",]
"alias": {
"~/": "./"
}
}]
]
}
try it
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.