Skip to content

Commit

Permalink
docs(config): describe the primary set of fields in .bemrc
Browse files Browse the repository at this point in the history
  • Loading branch information
qfox committed Feb 13, 2018
1 parent 0c67600 commit 4dbb567
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions packages/config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,40 @@

## Usage

### `.bemrc` fields

Field | Type | Purpose
--- | --- | ---
root | `Boolean` | Used to determine the root directory from the current one
naming | `string|Object` | Name of existing in [`naming.preset`](https://github.com/bem/bem-sdk/tree/master/packages/naming.presets) preset or custom definition
levels | `Array<LevelConf>` | List of known levels (usually local)<br>in the right order with their configurations
sets | `Object<string, string|Array<string>>` | Named sets of layers to use in projects
libs | `Object<string, LibraryConf>` | Dependency libraries to use in sets
plugins | `Object<string, PluginConf>` | Various configurations for plugins, can be reached via [`.module`](#module) method

#### `LevelConf`

Describes level with sources.
In classic version it represents a directory for a single layer — e.g. `bem-components/common.blocks/` for `common` or `bem-components/desktop.blocks/` for `desktop`.
In modern version represents a set of layers relative to library path (`.bemrc` location)
and depends on naming preset — e.g. `common` and `desktop` for just `bem-components/` (library) path and [`origin`](https://github.com/bem/bem-sdk/blob/master/packages/naming.presets/origin.js) preset.

- `layer` - name of level‘s layer to use in sets
- `naming` - naming preset for this level
- `path` - optional. required for legacy way, unwanted for the modern one
- the rest fields will have passed to level config

#### `LibraryConf`

- `path` - to library which should better contain their own `.bemrc` file with their own sets
- the rest fields will have passed to library config and extend `.bemrc` config found at `${path}/.bemrc`

#### `PluginConf`

- all the fields will have passed directly to plugins

## API

```js
const bemConfig = require('@bem/sdk.config');
const optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } };
Expand Down

0 comments on commit 4dbb567

Please sign in to comment.