{"id":14985741,"url":"https://github.com/bitfyre/config-merge-loader","last_synced_at":"2026-01-05T02:03:32.502Z","repository":{"id":57205398,"uuid":"95125953","full_name":"bitfyre/config-merge-loader","owner":"bitfyre","description":"Loader for mergeing environment specific localization or configuration into a base set at build time.","archived":false,"fork":false,"pushed_at":"2017-07-18T06:28:39.000Z","size":29,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-16T09:05:37.673Z","etag":null,"topics":["configuration","json","loader","webpack"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bitfyre.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-22T14:45:38.000Z","updated_at":"2022-07-17T12:37:08.000Z","dependencies_parsed_at":"2022-09-18T01:32:33.909Z","dependency_job_id":null,"html_url":"https://github.com/bitfyre/config-merge-loader","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfyre%2Fconfig-merge-loader","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfyre%2Fconfig-merge-loader/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfyre%2Fconfig-merge-loader/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bitfyre%2Fconfig-merge-loader/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bitfyre","download_url":"https://codeload.github.com/bitfyre/config-merge-loader/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244814984,"owners_count":20514861,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["configuration","json","loader","webpack"],"created_at":"2024-09-24T14:11:34.551Z","updated_at":"2026-01-05T02:03:32.424Z","avatar_url":"https://github.com/bitfyre.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# config-merge-loader for Webpack\n\nA webpack loader for merging configuration or localization files with a base set at build time. It should work with most loaders that generate JSON.\n\n## Installation\n\n`npm install config-merge-loader --save`\n\n## Usage\n\nThis is intended to be used with loaders that poduce a JSON out put, like the json-loader itself or the yaml-loader.\n\n### Basic Usage\n\n**base.json:**\n\n```json\n{\n  \"a\": 1,\n  \"b\": {\n    \"a\": 1,\n    \"b\": 1\n  },\n  \"c\": 1\n}\n```\n\n**override.json:**\n\n```json\n{\n  \"a\": 2,\n  \"b\": {\n    \"a\": 2\n  }\n}\n```\n\n**webpack.config.js:**\n\n```javascript\n{\n  …\n  module: {\n   rules: [\n     {\n       test: /\\.json$/, use: 'json-loader'\n     },\n     {\n       test: /base\\.json$/,\n       use: [\n         {\n           loader: 'config-merge-loader',\n           query: {\n             override: 'override.json'\n           }\n         }\n       ]\n      }\n    ]\n  }\n  …\n}\n\n```\n\nThen in your application code you can do the following\n\n**entry.js:**\n\n```javascript\nimport config from './base.json'\n\nconst appConfig = JSON.parse(config);\n\nconsole.log(appConfig);\n\n```\n\nConsole result:\n\n```javascript\n{\n  a: 2,\n  b: {\n    a: 2,\n    b: 1\n  },\n  c: 1\n}\n```\n\n### Usage With `yaml-loader`\n\n**base.yml:**\n\n```yaml\na: 1\nb:\n  a: 1\n  b: 1\nc: 1\n```\n\n**override.yml:**\n\n```yaml\na: 2\nb:\n  a: 2\n```\n\n**webpack.config.js:**\n\n```javascript\n{\n  …\n  module: {\n    rules: [\n      {\n        test: /\\.yml$/, use: [\n          { loader: 'json-loader' },\n          { loader: 'yaml-loader' }\n        ]\n      },\n      {\n        test: /base\\.yml$/,\n        use: [\n          {\n            loader: 'config-merge-loader',\n            query: {\n              override: 'override.yml'\n            }\n          },\n          { loader: 'yaml-loader' }\n        ]\n      }\n    ]\n  }\n  …\n}\n```\n\nThen in your application code you can do the following\n\n**entry.js:**\n\n```javascript\nimport config from './base.yml'\n\nconst appConfig = JSON.parse(config);\n\nconsole.log(appConfig);\n```\n\nConsole result:\n\n```javascript\n{\n  a: 2,\n  b: {\n    a: 2,\n    b: 1\n  },\n  c: 1\n}\n```\n\n### Usage When Merging Different Namespaces\n\n**base.yml:**\n\n```yaml\nlocale:\n  a: 1\n  b:\n    a: 1\n    b: 1\n  c: 1\n```\n\n**override.yml:**\n\n```yaml\noverride:\n  a: 2\n  b:\n    a: 2\n```\n\n**webpack.config.js:**\n\n```javascript\n{\n  …\n  module: {\n    rules: [\n      {\n        test: /\\.yml$/, use: [\n          { loader: 'json-loader' },\n          { loader: 'yaml-loader' }\n        ]\n      },\n      {\n        test: /base\\-namespace\\.yml$/,\n        use: [\n          {\n            loader: 'config-merge-loader',\n            query: {\n              baseNamespace: 'locale',\n              override: 'override-namespace.yml',\n              overrideNamespace: 'override'\n            }\n          },\n          { loader: 'yaml-loader' }\n        ]\n      }\n    ]\n  }\n  …\n}\n```\n\nThen in your application code you can do the following\n\n**entry.js:**\n\n```javascript\nimport locale from './base-namespace.yml'\n\nconst appLocale = JSON.parse(locale);\n\nconsole.log(appLocale);\n```\n\nConsole result:\n\n```javascript\n{\n  locale: {\n    a: 2,\n    b: {\n      a: 2,\n      b: 1\n    },\n    c: 1\n  }\n}\n```\n\n## Options\n\n`override` (required) string: Path to the override file. This will be merged in into the base file that is defined via an `import` or `require` statement.\n\n`baseNamespace` (optional) string: the name of the key for the base object. This results in this name being kept in the output, and only it properties inside of it being updated.\n\n`overrideNamespace` (optional) string: the name of top level key in the override object that will be used to override the base object.\n\n**Note:** Currently `baseNamespace` and `overrideNamespace` can only select one level deep.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfyre%2Fconfig-merge-loader","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbitfyre%2Fconfig-merge-loader","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbitfyre%2Fconfig-merge-loader/lists"}