1.0.3 • Published 10 years ago
simple-rc v1.0.3
simple-rc
a simple configuration loader
install
with npm, run
npm install --save simple-rcwhat
given a list of file paths,
- an empty config object is created
- each file path is rendered as a template string with
process.envpassed as local variables - the contents of each file path is read synchronously
- the contents are assigned deeply into the config object
- the config object is returned
usage
pass options in js
// config.js
const join = require('path').join
module.exports = require('simple-rc')({
files: [
"./config/${NODE_ENV}",
"./config"
]
})or in package.json
// config.js
module.exports = require('simple-rc')(){
"rc": {
"files": [
"./config/${NODE_ENV}",
"./config"
]
}
}to use in the browser, we recommend browserify and evalify transform.
in your package.json, add
{
"browserify": {
"transform": [
[ "evalify", { "files": "config.js" } ]
]
}
}then when you require your config.js file from within your browser code, it will be exported as only the evaluated object.