Find file History
zxqfox Publish
 - @bem/sdk.bemjson-node@0.0.6
 - @bem/sdk.bemjson-to-decl@0.2.9
 - @bem/sdk.bemjson-to-jsx@0.2.7
 - @bem/sdk.bundle@0.2.9
 - @bem/sdk.cell@0.2.7
 - @bem/sdk.config@0.0.10
 - @bem/sdk.decl@0.3.4
 - @bem/sdk.deps@0.2.9
 - @bem/sdk.entity-name@0.2.9
 - @bem/sdk.file@0.3.3
 - @bem/sdk.graph@0.2.7
 - @bem/sdk.naming.cell.match@0.1.0
 - @bem/sdk.naming.cell.pattern-parser@0.0.6
 - @bem/sdk.naming.cell.stringify@0.0.10
 - @bem/sdk.naming.entity.parse@0.2.7
 - @bem/sdk.naming.entity.stringify@1.1.0
 - @bem/sdk.naming.entity@0.2.8
 - @bem/sdk.naming.file.stringify@0.1.8
 - @bem/sdk.naming.presets@0.1.0
 - @bem/sdk.walk@0.3.0
Latest commit 5ab2f58 Jul 2, 2018
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
lib Support old node.js Nov 7, 2017
plugins Introduce sets Nov 7, 2017
test config: Support for layer without path and custom cwd Mar 24, 2018
CHANGELOG.md Publish Jul 1, 2018
LICENSE.txt chore(LICENSE): forever and ever Jan 16, 2018
README.md Introduce sets Nov 7, 2017
index.js config: Support for layer without path and custom cwd Mar 24, 2018
package.json Publish Jul 1, 2018

README.md

config

Usage

const bemConfig = require('@bem/sdk.config');
const optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } };
const projectConfig = bemConfig(optionalConfig); // returns BemConfig instance

options

All options are optional:

  • name // base name for rc files. Default value is bem.
  • cwd // Default value is process.cwd().
  • defaults // extends found configs with this object
  • pathToConfig // custom path to config on FS
  • fsRoot // custom '/' directory
  • fsHome // custom $HOME directory
  • plugins // 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
});

levels

const config = require('@bem/sdk.config')();
config.levels('desktop').then(function(desktopSet) {
    console.log(desktopSet); // an array of levels configs for desktop set
});

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 rc

levelSync

const config = require('@bem/sdk.config')();
const levelConf = config.levelSync('path/to/level');
console.log(levelConf); // merged level config

librarySync

const config = require('@bem/sdk.config')();
const libConf = config.librarySync('bem-components');
console.log(libConf); // library config

levels

const config = require('@bem/sdk.config')();
const desktopSet = config.levels('desktop'); // Note that this is a sync function because we have all the data
console.log(desktopSet); // an array of levels configs for desktop set

levelMapSync

const config = require('@bem/sdk.config')();
const levelMap = config.levelMapSync();
console.log(levelMap); // all levels hash with their options

moduleSync

const config = require('@bem/sdk.config')();
const bemToolsConf = config.moduleSync('bem-tools')
console.log(bemToolsConf); // merged config for required module

configs

const config = require('@bem/sdk.config')();
const configs = config.configs(true);
console.log(configs); // all found configs from all dirs

Config example

.bemrc:

{
    "root": true,
    "levels": [
        {
            "path": "path/to/level",
            "scheme": "nested"
        }
    ],
    "libs": {
        "libName": {
            "path": "path/to/lib"
        }
    },
    "sets": {
        // Will use `touch-phone` set from bem-components and few local levels
        "touch-phone": "@bem-components/touch-phone common touch touch-phone",
        "touch-pad": "@bem-components common deskpad touch touch-pad",
        // Will use `desktop` set from `bem-components`, and also few local levels
        "desktop": "@bem-components common deskpad desktop",
        // Will use mix of levels from `desktop` and `touch-pad` level sets from `core`, `bem-components` and locals
        "deskpad": "desktop@core touch-pad@core desktop@bem-components touch-pad@bem-components desktop@ touch-pad@"
    },
    "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.