關於babel-plugin-root-import使用的問題

找了好多關於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"
            }
          ]
        }
      ]
    ]
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章