Error: .plugins[0][1] must be an object, false, or undefined (Multiple custom prefixes)
Markus357 opened this issue · 1 comments
Markus357 commented
Build fails with Multiple custom prefixes and suffixes:
Running @babel/core: 7.4.0
/ webpack: 4.29.6
Build Error:
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: .plugins[0][1] must be an object, false, or undefined
at assertPluginItem
Webpack config:
plugins: [
[ "babel-plugin-root-import", [{
"rootPathPrefix": "~",
"rootPathSuffix": "./"
}, {
"rootPathPrefix": "!",
"rootPathSuffix": "./app"
}, {
"rootPathPrefix": "$",
"rootPathSuffix": "./web-components"
}, {
"rootPathPrefix": "#",
"rootPathSuffix": "./assets"
}
]],
],
If anyone else is experiencing this, the following works as desired (though not exactly ideal):
plugins: [
[ "babel-plugin-root-import", { "rootPathPrefix": "~", "rootPathSuffix": "./" }],
[ "babel-plugin-root-import", { "rootPathPrefix": "!", "rootPathSuffix": "./app" }, "config2"],
[ "babel-plugin-root-import", { "rootPathPrefix": "$", "rootPathSuffix": "./web-components" }, "config3"],
[ "babel-plugin-root-import", { "rootPathPrefix": "#", "rootPathSuffix": "./assets" }, "config4"]
],
brigand commented
Thanks for the report. As far as I can tell, babel is rejecting this configuration structure, so unfortunately we can't support exactly this syntax.
I added docs for the workaround that was already implemented. Your code would change to the following:
plugins: [
["babel-plugin-root-import", {
"paths": [
{
"rootPathPrefix": "~",
"rootPathSuffix": "./"
},
{
"rootPathPrefix": "!",
"rootPathSuffix": "./app"
}, {
"rootPathPrefix": "$",
"rootPathSuffix": "./web-components"
}, {
"rootPathPrefix": "#",
"rootPathSuffix": "./assets"
}
]
}]
],