merge-jsons-webpack-plugin
merge-jsons-webpack-plugin copied to clipboard
Deep merge with file path
Hello!
Is it possible to do like so:
Your application structure:
/src/app/
|-- catalog
| |-- catalogItem
| | |-- locales
| | | |-- en.json
| | | `-- ru.json
| | `-- catalogItem.component.js
| |-- locales
| | |-- en.json
| | `-- ru.json
| `-- catalog.component.js
`-- user
|-- locales
| |-- de.json
| |-- en.json
| `-- ru.json
`-- user.component.js
After using the above gulpfile.js
:
/dist/locales/
|-- de.json
|-- en.json
`-- ru.json
The en.json
file will look like this:
{
"catalog": {
"catalogItem": {
// contents of `/src/app/catalog/catalogItem/locales/en.json`
},
// contents of `/src/app/catalog/locales/en.json`
},
"user": {
// contents of `/src/app/user/locales/en.json`
}
}
So you can obtain values using dot notation, catalog.catalogItem.headline
for example.
Gulp example: https://github.com/loginov-rocks/gulp-locales-bundler/blob/master/src/gulpLocalesBundler.js
Made a straightforward function FYI: https://github.com/loginov-rocks/locales-bundler/blob/master/src/localesBundler.js#L15-L42
@loginov-rocks apologies, I was little away from this repo, I will check this .By the way thanks for dropping the suggestion
@loginov-rocks , a new package 0.0.19 was published, is that something that could help you?