json_merger-loader
v1.0.1
Published
json_merger loader for webpack. Merge JSON with indicators such as @override, @match, @delete and @insert to tell the processor how to merge the files
Downloads
5
Maintainers
Readme
json_merger-loader
json_merger loader for webpack. Merge JSON with indicators such as @override
, @match
, @delete
and @insert
to tell the processor how to merge the files
installation
npm install json_merger-loader --save-dev
Usage
Take a look on usage of json_merger module here https://www.npmjs.com/package/json_merger
main.json:
{
"@extends": [
"fileA.json",
"fileB.json"
]
}
fileA.json:
{
"prop1": {
"prop_a": "this will override fileB.json's property prop1"
},
"prop2": {
"prop_a": "some value"
},
"arr": [
{
"prop1": "value1"
}
]
}
fileB.json:
{
"prop3": {
"prop_b": "never gonna be seen"
},
"prop4": {
"prop_b": "some other value"
},
"arr": [
{
"@append": true,
"prop2": "value2"
}
]
}
Result:
{
"prop1": {
"prop_a": "value1"
},
"prop2": {
"prop_a": "value2"
},
"arr": [
{
"prop1": "arr value1"
},
{
"prop2": "arr value2"
}
],
"prop3": {
"prop_b": "value3"
},
"prop4": {
"prop_b": "value4"
}
}
Example config
module.exports = {
module: {
loaders: [
{
test: /\.json$/,
loaders: ['json', 'json_merger']
}
]
}
};
License
MIT - Copyright (c) 2016 Igor Kopach