Skip to content

Ibrahimrahhal/webpack-extend-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Webpack Extend JSON

Webpack loader that enables you to extend JSON file.

Note: this loader is still under development & not ready to be used in production

Getting Started

To begin, you'll need to install webpack-extend-json:

npm install --save-dev webpack-extend-json

Then add the loader to your webpack config for a specific file type. For example:

webpack.config.js

module.exports = {
  module: {
    rules: [
      {
        test: /\.json/i,
        loader: 'webpack-extend-json',
      },
    ],
  },
};

Example

You need to have two keys in your JSON "Extend" key which is the file to the file you want to extend & "data" key which is data in the JSON file

Parent.json

{
  "config1": "value1",
  "config2": "value2",
  "config3": "value3",
  "config4": "value4"
}

Child.json

{
  "extends": "./Parent.json", 
  "data": {
    "config3": "value3 - override",
    "config4": "value4 - override",
    "config5": "value5 - new value",
  }
}

the loaded JSON will look like this

{
  "config1": "value1",
  "config2": "value2",
  "config3": "value3 - override",
  "config4": "value4 - override",
  "config5": "value5 - new value",
}

Contributing

Please take a moment to read our contributing guidelines if you haven't yet done so.

CONTRIBUTING

License

MIT

About

Webpack loader that enables you to extend JSON file.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published