Package Exports
- @bem/sdk.config
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@bem/sdk.config) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
config
Usage
const bemConfig = require('@bem/sdk.config');
const optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } };
const projectConfig = bemConfig(optionalConfig); // returns BemConfig instanceoptions
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
const config = require('@bem/sdk.config')();
config.get().then(function(conf) {
console.log(conf); // config is a merge of CLI args + optionalConfig + all configs found by rc
});level
const config = require('@bem/sdk.config')();
config.level('path/to/level').then(function(levelConf) {
console.log(levelConf); // merged level config
});library
const config = require('@bem/sdk.config')();
config.library('bem-components').then(function(libConf) {
console.log(libConf); // library config
});levelMap
const config = require('@bem/sdk.config')();
config.levelMap().then(function(levelMap) {
console.log(levelMap); // all levels hash with their options
});module
const config = require('@bem/sdk.config')();
config.module('bem-tools').then(function(bemToolsConf) {
console.log(bemToolsConf); // merged config for required module
});configs
const config = require('@bem/sdk.config')();
config.configs().then(function(configs) {
console.log(configs); // all found configs from all dirs
});Sync API
getSync
const config = require('@bem/sdk.config')();
const conf = config.getSync();
console.log(conf); // config is a merge of CLI args + optionalConfig + all configs found by rclevelSync
const config = require('@bem/sdk.config')();
const levelConf = config.levelSync('path/to/level');
console.log(levelConf); // merged level configlibrarySync
const config = require('@bem/sdk.config')();
const libConf = config.librarySync('bem-components');
console.log(libConf); // library configlevelMapSync
const config = require('@bem/sdk.config')();
const levelMap = config.levelMapSync();
console.log(levelMap); // all levels hash with their optionsmoduleSync
const config = require('@bem/sdk.config')();
const bemToolsConf = config.moduleSync('bem-tools')
console.log(bemToolsConf); // merged config for required moduleconfigs
const config = require('@bem/sdk.config')();
const configs = config.configs(true);
console.log(configs); // all found configs from all dirsConfig example
.bemrc:
{
"root": true,
"levels": [
{
"path": "path/to/level",
"scheme": "nested"
}
],
"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": "path/to/level",
"techs": ["bemhtml.js", "trololo.olo"],
"default": true
}
]
}
}
},
"bem-libs-site-data": {
"someOption": "someValue"
}
}
}levels override common options.
License
Code and documentation © 2015-2017 YANDEX LLC. Code released under the Mozilla Public License 2.0.