-
Notifications
You must be signed in to change notification settings - Fork 265
Closed
Description
Hello,
the current implementation doesn't insert the plugin (in my case I tried with addBabelPlugin(['emotion'])(config)
).
This doesn't match the babel-loader
:
Array.isArray(r.use) && r.use.some(u => u.options && u.options.babelrc != void 0)
because the babel-loader doesn't have a use
key.
The two characteristics I use to spot the right babel-loader (there are 2 of them) are :
- The loader name contains "babel-loader"
- It has a "customize" key
function addBabelPlugin(plugin) {
return function(config) {
const babelLoader = config.module.rules
.find(rule => Object.keys(rule).includes('oneOf'))
.oneOf.find(
rule =>
rule.loader &&
rule.loader.includes('babel-loader') &&
rule.options.customize
)
babelLoader.options.plugins.push(plugin)
return config
}
}
war3k
Metadata
Metadata
Assignees
Labels
No labels