# js.conf.d

> A simple config loader with folder overrides

Latest version **2.0.0** (published 2025-02-03) · BSD-3-Clause license · 0 weekly downloads

## Install

```sh
npm install js.conf.d
pnpm add js.conf.d
yarn add js.conf.d
bun add js.conf.d
```

## Health

**Score 30/100 (F)** — status: maintenance-mode.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-02-03 |
| First published | 2019-09-06 |
| Weekly downloads | 0 |
| License | BSD-3-Clause |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 6.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Anxo Soto |
| Maintainers | mancontr, linuxgunter |
| Keywords | config, loader, overrides |

## Links

- npm: https://www.npmjs.com/package/js.conf.d
- Repository: https://github.com/mancontr/js.conf.d
- Homepage: https://github.com/mancontr/js.conf.d#readme
- Issues: https://github.com/mancontr/js.conf.d/issues
- npm.io page: https://npm.io/package/js.conf.d

## Alternatives

- [jsforce](https://npm.io/package/jsforce.md) — 851.2K weekly downloads
- [react-native-qrcode-svg](https://npm.io/package/react-native-qrcode-svg.md) — 693.5K weekly downloads
- [@salesforce/plugin-data](https://npm.io/package/@salesforce/plugin-data.md) — 394.9K weekly downloads
- [@backstage/plugin-search-common](https://npm.io/package/@backstage/plugin-search-common.md) — 308.5K weekly downloads
- [@chain-registry/types](https://npm.io/package/@chain-registry/types.md) — 38.4K weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-02-03
- 2.0.1 (next) — 2025-03-05
- 1.3.0 — 2020-03-04
- 1.2.1 — 2019-10-03
- 1.2.0 — 2019-09-22
- 1.1.1 — 2019-09-07
- 1.1.0 — 2019-09-07
- 1.0.2 — 2019-09-06
- 1.0.1 — 2019-09-06
- 1.0.0 — 2019-09-06

## README

[![Build Status](https://travis-ci.com/mancontr/js.conf.d.svg?branch=master)](https://travis-ci.com/mancontr/js.conf.d)

# js.conf.d

A simple configuration manager, with directory hierarchy / overrides support.

Linux distributions' packages have had folder-based config for years. We're all used to easily adding files to a `nginx.conf.d` folder, and it being picked up automatically, in a predictable order. We're also used to having multiple paths where config will be searched, ordered by priority. But until now, on Node.js we had to do this manually.

This package allows you to set a list of search folders, and any js files on them will be loaded and merged as a plain object, following configurable rules.

## Usage

Using js.conf.d is very simple:

```js
const jsconfd = require('js.conf.d')

// Load config from any of these 3 folders, with the latter overriding the former
const config = jsconfd.load(['/etc/my-config', '~/.my-config', './config'])
```

By default, the files will be loaded on filename order (as defined by `sort()`), and the contents will be merged using `Object.assign`. You can customize this behaviour by passing a options object as a second parameter, with the following keys:

```js
const config = jsconfd.load(['/etc/my-config', '~/.my-config', './config'], {
  sort: (a, b) => { /*...*/ }, // Argument to sort() the filenames. Defaults to null.
  merge: (a, b) => { /*...*/ } // Value merger function. Defaults to Object.assign.
})
```

## Using with Webpack

This package is designed for Node.js, and doesn't work directly on Webpack. Fortunately, we have created a small Webpack plugin which implements the same logic. Check [js.conf.d-webpack](https://github.com/mancontr/js.conf.d-webpack).

---
_Source: https://npm.io/package/js.conf.d · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
