BEM import
BEM-entities auto resolver for custom import strings.
;;;;;;
Install
npm i -D babel-plugin-bem-import
Babel version
For babel-7 use babel-plugin-bem-import@2
For babel-6 use babel-plugin-bem-import@1
Usage
.babelrc
Options
- naming: bem-naming overrides
- levels : paths to components declarations
- techs : list of techs extensions for require in runtime,
['js']
by default - techMap : mapping of techs to extensions. Example:
{ 'js' : ['react.js', 'react.ts', 'react.es'], 'css' : ['post.css'] }
- langs : list of langs in which resloves '.i18n' tech
i18n
.i18n
- represent special technology that provides the opportunity to localize components.
For correct working you need to install bem-i18n
inside your project.
npm i -S bem-i18n
On file system:
blocks/Attach/
├── Attach.react.js
├── Attach.i18n
│ ├── en.js
│ ├── ru.js
│ └── tr.js
└── Attach.spec.js
en.js
, ru.js
and tr.js
are keysets and should be common.js modules.
$ cat blocks/Attach/Attach.i18n/tr.jsmodule.exports = ;
inside Attach.react.js
:
console // → Dosya seç
babel-import
transpiles such code to
var i18n = { var core = ; if processenvBEM_LANG === 'ru' return 'Attach' if processenvBEM_LANG === 'en' return 'Attach' if processenvBEM_LANG === 'tr' return 'Attach' }; console // → Dosya seç
process.env.BEM_LANG
is need to be defined. ru
, en
and tr
are taken from langs
option.