webpack-configurator
webpack-configurator copied to clipboard
Save location where a config setting was set
This would be super cool, but could be a bit complex.
Using the callsite
npm module, whenever a configurator method is called, for each plain object modified, add a hidden $callsite: []
field, and store the filename and line number of the file that set it. Each modification is pushed to the array.
Then in the print
method, you could indicate in which file a particular config key was set.
Why?
When splitting up configs, and maybe having some default configs come from an npm module, it would be useful to know where the setting was set.
Layering configs based on function is useful. E.g. the inclusion of a single module may require a few configurations. If this module is removed, or disabled, so should the webpack config. In the other direction, it would allow you to construct configs automatically when including a module that requires some configs.
Lots of modules require certain webpack config settings.
Examples:
-
bootstrap-sass-loader
requires you to add this config for fonts, and a jquery import setting, and a plugin! -
Protobufjs
requires
resolve.alias: {
protobufjs: 'protobufjs/dist/ProtoBuf-light', // `-light` = don't include .proto loader. We only use JSON loader.
ByteBuffer: 'bytebuffer',
Long: 'long',
}
But this layering requires easy to access printing of resolved configs and tracing where options are set from otherwise you end up in config hell!