bem-react-components icon indicating copy to clipboard operation
bem-react-components copied to clipboard

Rename folder blocks → common.blocks

Open Vittly opened this issue 7 years ago • 8 comments

Needed to build it with webpack-bem-plugin.

Why?

  1. Plugin is built on bem-sdk — new version of bem-tools/bem-config
  2. Modern version of bemrc (used by bem-sdk) should define level in a form { layer: 'foo' } for folder "foo.blocks". Defining level with path property is deprecated
  3. Naming presets also relay on layer property

There is no simple way to handle "bem-react-components" with custom folder "blocks" and build projects by webpack-bem-plugin or other builder using bem-sdk.

I've created an issue about it and found no other way. May be after this issue we can get better decision. For now is better to use simple approach: "If bem-react-components defines common blocks we put them in so called folder"

Vittly avatar Mar 17 '18 18:03 Vittly

@awinogradov @Yeti-or check my PR please

Vittly avatar Mar 17 '18 18:03 Vittly

сс @tadatuta

awinogradov avatar Mar 19 '18 12:03 awinogradov

I think bem-config should support folders like blocks, blocks-common and all the other custom variations. will find out the way to support it.

tadatuta avatar Mar 19 '18 16:03 tadatuta

bem-config is deprecated see subtitle at github page. I am talking about bem-sdk/config

Vittly avatar Mar 20 '18 08:03 Vittly

@tadatuta reasonably noted that all we need is to declare a custom preset for "bem-react-components" like:

// based on react preset
module.exports = {
    delims: {
        elem: '-',
        mod: { name: '_', val: '_' }
    },
    fs: {
        delims: { elem: '' },
        pattern: 'blocks/${entity}.${tech}',
        scheme: 'nested'
    },
    wordPattern: '[a-zA-Z0-9]+'
};

But "bem-react-components" should be simple and such complex thing like full naming form is too much. May be we can give an option to define naming preset based on one of standard presets.

This is much simpler:

module.exports = {
    basedOn: 'react',
    fs: { patter: 'blocks/${entity}.${tech}' } 
};

Vittly avatar Mar 20 '18 10:03 Vittly

Actually, you can do this without basedOn field:

const { react } = '@bem/sdk.naming.presets';
module.exports = { ...react, fs: { ...react.fs, pattern: '${entity}.${tech}' } };

And path to library (or to level if you want) should contains blocks/.

btw. Do you want to join us at this weekend to dive into webpack world?

qfox avatar Mar 20 '18 23:03 qfox

basedOn is shorter =) we can add it here

Vittly avatar Mar 21 '18 06:03 Vittly

тогда уж extends

qfox avatar Mar 24 '18 12:03 qfox