Find and load a configuration object. based on cosmiconfig
npm i config-finder
- Support functionaly evaluation with customize context.
- Mixin multiple externals by
extends
property.
// cat package.json
{
...
"fss": {
"extends": [
"./.fssrc.js"
],
"foo": [ "bar" ]
}
}
// cat ./.fssrc.js
module.exports = (ctx) => {
return Object.assign({}, ctx,
{
rollup: { /* input, output */ }
}
}
const configFinder = require('config-finder')
const yourModuleName = 'fss'
const modConfig = configFinder(yourModuleName)
const cfg = modConfig(ctx[, path, options])
.then((result) => {
// result.config is the parsed configuration object
// result.filepath is the path to the config file that was found
})
.catch((parsingError) => {
// do something constructive
});
// sync mode
// const cfg = modConfig.sync(ctx[, path, options])