a minimal universal configuration loader
npm install --save conjig
you want to synchronously load a configuration object.
the configuration should be composed of many sources.
with npm, run
npm install --save conjig
pass options in js
// config.js
const getConfig = require('conjig')
module.exports = getConfig({
sources: [
"./config/${NODE_ENV}",
"./config"
]
})
or in package.json
// config.js
const getConfig = require('conjig')
module.exports = getConfig()
{
"conjig": {
"sources": [
"./config/${NODE_ENV}",
"./config"
]
}
}
options
is an object with:
sources
: an array of filenames- may include template string variables from
process.env
- may include template string variables from
config
is an object deeply merged with all config objects in sources.
to use in the browser
, use the browserify
compiler.
in your package.json, add
{
"browserify": {
"transform": [
"conjig/transform"
]
}
}
then when you call require('conjig')()
in the browser, it transforms to the result in node during compilation.
The Apache License
Copyright © 2016 Michael Williams
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.