bem-config
v3.2.3
Published
Config module for bem-tools
Downloads
736
Readme
bem-config
Usage
var bemConfig = require('bem-config');
var optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } };
var projectConfig = bemConfig(optionalConfig); // returns BemConfig instance
options
All options are optional:
name
// base name for rc files. Default value isbem
.cwd
// Default value isprocess.cwd()
.defaults
// extends found configs with this objectpathToConfig
// custom path to config on FSfsRoot
// custom '/' directoryfsHome
// custom $HOME directoryplugins
// array of paths to plugings to require
Async API
get
var config = require('bem-config')();
config.get().then(function(conf) {
console.log(conf); // config is a merge of CLI args + optionalConfig + all configs found by rc
});
level
var config = require('bem-config')();
config.level('path/to/level').then(function(levelConf) {
console.log(levelConf); // merged level config
});
library
var config = require('bem-config')();
config.library('bem-components').then(function(libConf) {
console.log(libConf); // library config
});
levelMap
var config = require('bem-config')();
config.levelMap().then(function(levelMap) {
console.log(levelMap); // all levels hash with their options
});
module
var config = require('bem-config')();
config.module('bem-tools').then(function(bemToolsConf) {
console.log(bemToolsConf); // merged config for required module
});
configs
var config = require('bem-config')();
config.configs().then(function(configs) {
console.log(configs); // all found configs from all dirs
});
Sync API
getSync
var config = require('bem-config')();
var conf = config.getSync();
console.log(conf); // config is a merge of CLI args + optionalConfig + all configs found by rc
levelSync
var config = require('bem-config')();
var levelConf = config.levelSync('path/to/level');
console.log(levelConf); // merged level config
librarySync
var config = require('bem-config')();
var libConf = config.librarySync('bem-components');
console.log(libConf); // library config
levelMapSync
var config = require('bem-config')();
var levelMap = config.levelMapSync();
console.log(levelMap); // all levels hash with their options
moduleSync
var config = require('bem-config')();
var bemToolsConf = config.moduleSync('bem-tools')
console.log(bemToolsConf); // merged config for required module
configs
var config = require('bem-config')();
var configs = config.configs(true);
console.log(configs); // all found configs from all dirs
Config example
.bemrc
:
{
"root": true,
"levels": {
"path/to/level": {
"scheme": "nested",
"default": true
}
},
"libs": {
"libName": {
"path": "path/to/lib"
}
},
"sets": {
"setName": ["level1", "level2"]
},
"modules": {
"bem-tools": {
"plugins": {
"create": {
"techs": [
"css", "js"
],
"templateFolder": "path/to/templates",
"templates": {
"js-ymodules": "path/to/templates/js"
},
"techsTemplates": {
"js": "js-ymodules"
},
"levels": {
"path/to/level": {
"techs": ["bemhtml.js", "trololo.olo"]
}
}
}
}
},
"bem-libs-site-data": {
"someOption": "someValue"
}
}
}
levels
override common options.
License
Code and documentation © 2015 YANDEX LLC. Code released under the Mozilla Public License 2.0.