Convention-based configuration
TODO
- Remove dependency on globals: CLIENT and DEVELOPMENT.
- Move
live-browser-config-requires-generated
dependency to tmp.
Install
npm i -S live-config
Usage
Project structure
config
default.js
development.js
production.js
modules
foo
index.js
config
default.js
development.js
production.js
bar
index.js
config
default.js
development.js
production.js
index.js
// config/default.jsmoduleexports = foo: key: '456'
// modules/foo/config/default.jsmoduleexports = key: '123'
config // 456
Scoped config.
const config = config // 456
Design
- Root config overrides all other config.
- Convention-based. Searches for a top-level config directory inside each module.
- Modules set default configuration by environment.
- A module's config is scoped to the module name from package.json.
Goals
- Predictable. Conventions for location of config directories and module-name scoping makes it easy to trace resolved configuration.
- Isomorphic. Works for Node.js and the browser.