Skip to content

Instantly share code, notes, and snippets.

@qfox
Last active April 11, 2019 01:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save qfox/8a7c1dab6c959afde0e295e31f24e2f8 to your computer and use it in GitHub Desktop.
Save qfox/8a7c1dab6c959afde0e295e31f24e2f8 to your computer and use it in GitHub Desktop.
module.exports = {
root: true,
levels: [
// Ordered array of levels if you need a specific order between levels in library or project
{
layer: 'common', // Должен быть уникальным
path: 'very-uncommon.blocks', // если сильно хочется (?)
fs: { scheme: 'flat', naming: 'secondary' },
naming: 'primary'
},
// Сначала более общие
{ layer: 'deskpad' },
{ layer: 'touch' },
// Потом более частные
{ layer: 'desktop' },
{ layer: 'touch-phone' },
'touch-phone', // Можно вообще строкой
'touch-pad',
],
libraries: {
'bem-components': { /* looks for `node_modules/${id}` by default */ },
},
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@'
},
// !!! in libs/bem-components/.bemrc.js
libraries: {
core: { path: 'node_modules/bem-core' },
},
sets: {
'desktop': '@core common desktop',
'touch-pad': '@core common touch touch-pad',
'touch-phone': '@core common touch touch-phone'
},
modules: { /*…*/ }
};
// blocks/button/button.css
// button.css // common
// button@desktop.css
// common.blocks/button/button.css
// blocks-common/button/button.css
// touch/button.css
// button@touch.css
// `blocks/{entity}{layer && later !== 'common' ? `@{layer}` : ''}.{tech}`
// `{layer ? `{layer}.` : ''}blocks/{entity}.{tech}`
module.exports = {
sets: {
'custom': '@desktop @touch-pad', // common deskpad desktop touch touch-pad
// commmon deskpad touch desktop touch-pad
}
};
//core
levels:
common
touch-pad
desktop
//comp
levels:
common
desktop
touch-pad
const BemConfig = require('@bem/sdk.config');
const bemconf = new BemConfig();
(async () => {
console.log(await bemconf.levels('desktop')); // set (platform)
// [ { path: 'common.blocks' }, { 'deskpad.blocks' }, { 'desktop.blocks' } ]
})();
const walk = require('@bem/sdk.walk');
const Config = require('@bem/sdk.config');
// const { walk, Config } = require('@bem/sdk');
const config = new Config({
/*?*/
defaults: {
naming: {}, // ?
schema: {}, // ?
// ?
}
});
await walk.asArray({
// levels: ['i-bem', './islands'],
set: 'desktop', // or array
cwd: process.cwd()
config
});
walk([], { path });
// i-bem/.bemrc: {schema: 'legacy', levels: [{layer: 'common'}, {layer: 'desktop'}], sets: {desktop: ['common']}}
// i-bem/common.blocks/*
// islands/.bemrc: {schema: 'legacy', sets: {desktop: ['common', 'desktop', {layer: 'qwe', lib: 'asd'}]}}
// islands/common.blocks/*
// islands/desktop.blocks/*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment