Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cletusw/fallback-multi-json-loader
Webpack loader to provide fallback keys & values for use with multi-json-loader
https://github.com/cletusw/fallback-multi-json-loader
Last synced: 2 months ago
JSON representation
Webpack loader to provide fallback keys & values for use with multi-json-loader
- Host: GitHub
- URL: https://github.com/cletusw/fallback-multi-json-loader
- Owner: cletusw
- License: mit
- Created: 2017-09-25T21:28:24.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2017-09-25T21:58:05.000Z (over 7 years ago)
- Last Synced: 2024-10-12T17:37:15.933Z (3 months ago)
- Language: JavaScript
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Fallback keys & values for use with multi-json-loader
## Install
```
npm install fallback-multi-json-loader
```## Usage
[Documentation: Using loaders](https://webpack.js.org/concepts/loaders/#using-loaders)
Returns a single JSON blob with keys and values made by calling `multi-json-loader` then merging in the result of the following loaders using [lodash `merge`](https://lodash.com/docs/#merge). If two leaf nodes conflict, the one from the following loaders (from `data/pt` in the below example) wins.
### ./data/en/account.json
```json
{
"both-key1": "both-key1-en-value",
"en-key1": "en-key1-value"
}
```### ./data/pt/account.json
```json
{
"both-key1": "both-key1-pt-value",
"pt-key1": "pt-key1-value"
}
```### example.js
```javascript
var data = require('json-loader!fallback-multi-json-loader?cwd=data/en!multi-json-loader?cwd=data/pt!./irrelevant.whatever');
// => {
// account: {
// 'both-key1': 'both-key1-pt-value',
// 'en-key1': 'en-key1-value',
// 'pt-key1': 'pt-key1-value'
// }
// }
```## Options
Same as [`multi-json-loader`](https://github.com/cletusw/multi-json-loader#options).
## License
MIT