Closed patricklafrance closed 5 years ago
Oh awesome! I was a bit confused about how that works, but that makes a lot of sense now! Thanks!
Hi @patricklafrance, just wanted to mention that this code actually has a bug in this line:
const { babel: { plugins = [] } = {} } = cracoConfig;
This does initialize a new plugins
array if it didn't already exist at cracoConfig.babel.plugins
, but it doesn't actually modify the original cracoConfig
variable. It just returns an empty array that isn't attached to anything.
You actually need to call this:
if (!cracoConfig.babel) cracoConfig.babel = {};
if (!cracoConfig.babel.plugins) cracoConfig.babel.plugins = [];
That will modify the data in the original cracoConfig
so that the changes to plugins
will be saved when you call return cracoConfig
.
@ndbroadbent good catch, sorry about that!
You don't need to merge it, I wanted to show you that you could also use
overrideCracoConfig
to add a babel plugin