找了好多关于babel-plugin-root-import的使用方法,单个的时候都对,定义多组别名入口的时候就挂了。
使用方法(本人照以下使用报错):
定义多组别名入口
{
"plugins": [
["babel-plugin-root-import", [{
"rootPathPrefix": "~", // `~` 默认
"rootPathSuffix": "src/js"
}, {
"rootPathPrefix": "@",
"rootPathSuffix": "other-src/js"
}, {
"rootPathPrefix": "#",
"rootPathSuffix": "../../src/in/parent" //也支持父级路径
}]]
]
}
官网:babel-plugin-root-import
亲测可以:
{
"plugins": [
[
"babel-plugin-root-import",
{
"paths": [
{
"rootPathPrefix": "@theme",
"rootPathSuffix": "pages/asess/themes"
},
{
"rootPathPrefix": "@component",
"rootPathSuffix": "pages/components"
}
]
}
]
]
}