Fitbit / webpack-config

Helps to load, extend and merge webpack configs
https://fitbit.github.io/webpack-config
Apache License 2.0
252 stars 18 forks source link

Extending duplicate deeply-nested configs #103

Open matthew-dean opened 7 years ago

matthew-dean commented 7 years ago

Problem: I am using Nuxt.js which exports an extendable config for webpack. I'd like to extend "sass-loader" in that config, BUT...

  1. The root list of module loaders contains both "vue-loader" and "sass-loader", with respective options.
  2. Under "vue-loader" options, it contains a loaders property, which has a sub-property of sass, which contains an array of loaders, ONE of which is "sass-loader", which then, of course has a list of duplicated options for "sass-loader".

I'd like to use webpack-config to extend/merge instances of "sass-loader" wherever { loader: 'sass-loader' } is found in the entire config sub-tree. (Ideally, I would also check that the exported config doesn't have any variation between duplicate loader options.)

Can a feature be added where merging includes a deep key/value lookup of the object tree, and then merges the options at that location? Or can you think of another way to do this?

Thanks.

mdreizin commented 7 years ago

Hello @matthew-dean, I'm really sorry that I didn't respond earlier. Better late than never.

Yes, it sould be possible.

ConfigMergeCommand.js uses simple implementation based on lodash, but it could be replaced with webpack-merge. It is designed especially for merging webpack-configs.