Webpack loader that enables you to extend JSON file.
To begin, you'll need to install webpack-extend-json
:
npm install --save-dev webpack-extend-json
Then add the loader to your webpack
config for a specific file type. For example:
webpack.config.js
module.exports = {
module: {
rules: [
{
test: /\.json/i,
loader: 'webpack-extend-json',
},
],
},
};
You need to have two keys in your JSON "Extend" key which is the file to the file you want to extend & "data" key which is data in the JSON file
Parent.json
{
"config1": "value1",
"config2": "value2",
"config3": "value3",
"config4": "value4"
}
Child.json
{
"extends": "./Parent.json",
"data": {
"config3": "value3 - override",
"config4": "value4 - override",
"config5": "value5 - new value",
}
}
the loaded JSON will look like this
{
"config1": "value1",
"config2": "value2",
"config3": "value3 - override",
"config4": "value4 - override",
"config5": "value5 - new value",
}
Please take a moment to read our contributing guidelines if you haven't yet done so.