package
Webpack loader to load multiple JSON files into one structure
npm install multi-json-loaderGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
npm install multi-json-loader{
"placesKey": "places value"
}{
"accountKey": "account value"
}{
"profileKey": "profile value"
}/* Doesn't matter */var data = require('multi-json-loader?cwd=data&glob=**/*.json!./irrelevant.whatever');
// => {
// places: {
// placesKey: "places value"
// },
// users: {
// account: {
// accountKey: "account value"
// },
// profile: {
// profileKey: "profile value"
// }
// }
// }Note that because I don't understand webpack enough, you have to provide a valid resource file (./irrelevant.whatever above) even though it won't actually be loaded.
You can also use the loader's functionality independent of webpack.
var multiJsonLoader = require('multi-json-loader');
var messages = multiJsonLoader.loadFiles('./i18n' /*, optional glob - defaults to '*.json'*/);
console.log(messages);
// => { a: { 'a-key': 'a-value' }, b: { 'b-key': 'b-value' } }See no-webpack-example subdirectory.
cwd The current working directory in which to search. Defaults to process.cwd().glob Glob to match files against using node-glob. Defaults to *.json.Path parts in cwd will not be included in the aggregated JSON object, whereas path parts in glob will.
var data = require('multi-json-loader?cwd=a/b&glob=c/*.json!./irrelevant.whatever');
// => {
// c: {
// <contents of c directory>
// }
// }var data = require('multi-json-loader?glob=a/b/c/*.json!./irrelevant.whatever');
// => {
// a: {
// b: {
// c: {
// <contents of c directory>
// }
// }
// }
// }MIT
Estimated unpacked size across 9 packages.
6.9 MB
Includes dependencies.