找了好多關於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"
}
]
}
]
]
}