https://github.com/dsebastien/json-files-merge-loader
JSON files merge loader for Webpack
https://github.com/dsebastien/json-files-merge-loader
loader loaders plugin plugins webpack
Last synced: 2 months ago
JSON representation
JSON files merge loader for Webpack
- Host: GitHub
- URL: https://github.com/dsebastien/json-files-merge-loader
- Owner: dsebastien
- License: mit
- Created: 2016-09-12T07:08:45.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2018-06-02T16:38:29.000Z (about 8 years ago)
- Last Synced: 2025-10-24T04:28:50.770Z (8 months ago)
- Topics: loader, loaders, plugin, plugins, webpack
- Language: JavaScript
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.MD
Awesome Lists containing this project
README
# json-files-merge loader for webpack
## About
This plugin provides a way to merge multiple configuration files and retrieve the result as a JSON object. The JSON files are merged using https://www.npmjs.com/package/merge
This loader expects to receive a configuration JSON object with the following format:
```
{
"files": [
// path to all files to load/merge together
]
}
```
Each file listed in the `files` array must be a JSON file.
The path for each file must be a relative path starting from the root of your application module (e.g., src/filesToMerge/file1.json)
## Installation
`npm install --save json-merge-loader`
## Usage
``` javascript
let mergedConfiguration = require("./config-root.json-merge");
// => returns a module representing the merge of all the entries in the "file" array defined within config-root.json
```
The above will work assuming that you have configured the loaders for all json-merge files as follows:
```
loaders: [
// Support for *.json files
{
test: /\.json-merge$/,
loaders: [
"raw-loader",
"json-merge-loader",
]
}
],
```
Don't forget to polyfill `require` if you want to use it in node.
See `webpack` documentation.
## Configuration
You can configure the JSON Merge Loader in your webpack configuration:
```
"use strict";
// Webpack config
module.exports = {
...
// (optional) configuration of the JSON Merge Loader
jsonMergeLoader: {
debug: true,
...
},
};
```
Supported options:
* debug (true|false): verbose output
* TIP: by default, the "debug" property of the Webpack configuration is used, but you can override the value for this loader
## License
MIT (http://www.opensource.org/licenses/mit-license.php)