diff --git a/packages/config/README.md b/packages/config/README.md index 1c3b27fa..f261873e 100644 --- a/packages/config/README.md +++ b/packages/config/README.md @@ -2,6 +2,74 @@ ## Usage +### `.bemrc` fields + +Field | Type | Purpose +--- | --- | --- +root | `Boolean` | Used to determine the root directory. Configs in parent dirs won't be gathered +naming | `string`, `Object` | Name of one of [naming presets](https://github.com/bem/bem-sdk/tree/master/packages/naming.presets) or custom naming definition +levels | `Array` | List of known levels in the right order
(usually local) with their configurations +sets | `Object` | Named sets of layers to build +libs | `Object` | Dependency libraries to use in sets +plugins | `Object` | Various configurations for plugins,
can be reached via [`.module`](#module) method + +#### `root` + +For the following file structure +``` +/ + projects/ + prj1/ + .bemrc + .bemrc + .bemrc +``` +and `/projects/prj1/` as current working directory `root` option set to `true` in `/projects/prj1/.bemrc` will prevent `bem-config` to collect data from `/projects/.bemrc` and `/.bemrc`. + +#### `LevelConf` + +Describes [redefinition level](https://en.bem.info/methodology/key-concepts/#redefinition-level) with sources — a set of layers relative to library path (`.bemrc` location) +and depends on naming preset. E.g. `common` and `desktop` for `bem-components/` (library) path and [`origin`](https://github.com/bem/bem-sdk/blob/master/packages/naming.presets/origin.js) preset. + +Usualy it represents a directory for a single layer — e.g. `bem-components/common.blocks/` for `common` or `bem-components/desktop.blocks/` for `desktop`. + +- `layer` - name of level‘s layer to use in `sets` option +- `naming` - naming preset for this level +- `path` - optional, deprecated. Required for legacy way, unwanted for the modern one +- the rest fields will be passed to level config (if required by some custom consumer) + +##### Example +```js +{ + "levels": [ + { + "layer": "common", + "naming": "origin", + "scheme": "nested" + } + ] +} +``` + +#### `SetConf` + +`string|Array` + +One of: +- single string with all used layers; e.g. `'bem-core@ common deskpad desktop'` +- list of layers and/or libraries and library sets; e.g. `[{library: 'bem-core'}, 'common', 'deskpad', 'desktop']` + +#### `LibraryConf` + +- `path` - path (repeating is okey) to library. Library should contain its own .bemrc file. If omitted path is evaluated to node_modules/${libraryName} +- the rest fields will be passed to library config and extend `.bemrc` config found at `${path}/.bemrc` + +#### `PluginConf` + +- all the fields will be passed directly to plugins + +## API + ```js const bemConfig = require('@bem/sdk.config'); const optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } };