-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
config: describe the main fields #284
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<LevelConf>` | List of known levels in the right order<br> (usually local) with their configurations | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feels like we don't need the difference between levels and libraries — in all cases they are the same. Let's drop this field in favor of If we need to configure some directory (originally levels) with additional fields we should convert them to libraries and define in So:
|
||
sets | `Object<string, SetConf>` | Named sets of layers to build | ||
libs | `Object<string, LibraryConf>` | Dependency libraries to use in sets | ||
plugins | `Object<string, PluginConf>` | Various configurations for plugins,<br>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`. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Too complicated. We shall to come up with basic process of Start with more realistic example:
And tell "config of project contains of two |
||
|
||
#### `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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "a set of layers relative to library path (...)" - is very good. The second part is not. Can we simply add some examples:
Am I right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You are right. We want to merge |
||
|
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess we don't need to write There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
- `naming` - naming preset for this level | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is default value here? Root There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Guess, it should be |
||
- `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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, it's deprecated... So example above is bad idea. Can we put properties in a table |
||
|
||
##### Example | ||
```js | ||
{ | ||
"levels": [ | ||
{ | ||
"layer": "common", | ||
"naming": "origin", | ||
"scheme": "nested" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. scheme? Is it an example of custom property? Can we add a comment for it? |
||
} | ||
] | ||
} | ||
``` | ||
|
||
#### `SetConf` | ||
|
||
`string|Array<string|{library: string, set?: string}>` | ||
|
||
One of: | ||
- single string with all used layers; e.g. `'bem-core@ common deskpad desktop'` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mistake. Right form is |
||
- list of layers and/or libraries and library sets; e.g. `[{library: 'bem-core'}, 'common', 'deskpad', 'desktop']` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please add variant with library and set in one item There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. actually, if set is undefined then the current one will be used by default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Your definition "if set is undefined then the current one will is used by default" is okey. Write more short sentences There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In this version we missed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "targets specific layer in library" |
||
|
||
#### `LibraryConf` | ||
|
||
- `path` - path (repeating is okey) to library. Library should contain its own .bemrc file. If omitted path is evaluated to node_modules/${libraryName} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please put bemrc and node_modules/... in ticks |
||
- the rest fields will be passed to library config and extend `.bemrc` config found at `${path}/.bemrc` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems it is not true. |
||
|
||
#### `PluginConf` | ||
|
||
- all the fields will be passed directly to plugins | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What plugins? Can we add an example? |
||
|
||
## API | ||
|
||
```js | ||
const bemConfig = require('@bem/sdk.config'); | ||
const optionalConfig = { plugins: { create: { techs: ['styl', 'browser.js'] } } }; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And default value?