All Projects → bem → webpack-bem-loader

bem / webpack-bem-loader

Licence: other
Webpack BEM loader

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to webpack-bem-loader

bem-react-boilerplate
DEPRECATED! A bare minimum frontend boilerplate based on create-react-app and bem-react-core.
Stars: ✭ 32 (+28%)
Mutual labels:  bem, bem-react
emma.css
🍴 Emma.css { utility-classes: emmet-like; }
Stars: ✭ 53 (+112%)
Mutual labels:  bem
Gulp Pug Starter
Frontend development with pleasure. Pug + SCSS version
Stars: ✭ 228 (+812%)
Mutual labels:  bem
openmeeg
A C++ package for low-frequency bio-electromagnetism solving forward problems in the field of EEG and MEG.
Stars: ✭ 62 (+148%)
Mutual labels:  bem
hyper
🎨 Hyper: A component-first CSS design system.
Stars: ✭ 26 (+4%)
Mutual labels:  bem
vue-bem-cn
✅ vue-bem-cn - Simple BEM class name generator for Vue.JS
Stars: ✭ 124 (+396%)
Mutual labels:  bem
Holy Grail Markup
All CSS methodologies compared examples at one place.
Stars: ✭ 197 (+688%)
Mutual labels:  bem
bootstrap-shopify-theme
🛍 A free Shopify Theme built with Bootstrap, BEM, Liquid, Sass, ESNext, Theme Tools, ... and Webpack.
Stars: ✭ 41 (+64%)
Mutual labels:  bem
bem-animations
🔔 Easy and Fast in use (based on Animate CSS)
Stars: ✭ 13 (-48%)
Mutual labels:  bem
marmelad
Заготовка фронтенд проекта для продвинутых и начинающих 🤘. Хорошо подходит для поддержания единой структуры проектов в команде и легкого переиспользования готовых блоков между проектами.
Stars: ✭ 15 (-40%)
Mutual labels:  bem
dumb-bem
Simple BEM react components generator
Stars: ✭ 32 (+28%)
Mutual labels:  bem
ts-react-boilerplate
A very opinionated (React/TypeScript/Redux/etc) frontend boilerplate
Stars: ✭ 43 (+72%)
Mutual labels:  bem
ekzo
💫 Functional Sass framework for rapid and painless development
Stars: ✭ 32 (+28%)
Mutual labels:  bem
vue-simple-bem
A simple Vue.js directive to map BEM CSS class names.
Stars: ✭ 17 (-32%)
Mutual labels:  bem
frontend-app
A Eventos ❤️ do Bem é uma plataforma de arrecadação de recursos P2P dedicada a ONGs, cujo objetivo é transformar eventos comemorativos e divertidos da vida das pessoas em motivação para campanhas de arrecadação voltadas a projetos socioambientais.
Stars: ✭ 15 (-40%)
Mutual labels:  bem
Yandex Ui
Yandex UI Kit build on React and bem-react
Stars: ✭ 229 (+816%)
Mutual labels:  bem
is-my-train-delayed
An Angular web app built on Heroku with Node & Express. Shows information about delayed trains, and displays that in an easily consumable manner.
Stars: ✭ 15 (-40%)
Mutual labels:  bem
buttono
A flexible Sass mixin for creating BEM-style buttons.
Stars: ✭ 82 (+228%)
Mutual labels:  bem
web-starter-kit-gulp
Starter kit for automated front-end web development using Gulp, NPM, Bower, Babel, Sass, and Pug.
Stars: ✭ 35 (+40%)
Mutual labels:  bem
enb-bem-techs
ENB package to build BEM-projects
Stars: ✭ 23 (-8%)
Mutual labels:  bem

Webpack BEM loader

Webpack loader for bem-react-core

BEM entities auto resolver for custom import strings:

import Block from 'b:block';
import Block from 'b:block m:modName';
import Block from 'b:block m:modName=modVal1|modVal2';
import BlockElem from 'b:block e:elem';
import BlockElem from 'b:block e:elem m:modName';
import BlockElem from 'b:block e:elem m:modName=modVal1|modVal2';

Install

npm i -D webpack-bem-loader

Usage

In your webpack.config.js.

Webpack 1

  // setting for bem-loader
  bemLoader: {
    naming: 'react',
    levels: ['./pathToBlocks'],
    // OR:
    // levels: {
    //     './pathToBlocks': {
    //         default: true,
    //         scheme: 'nested',
    //         naming: 'origin'
    //     }
    // },
    techs: ['js', 'css'],
    techMap: {
        js : ['react.js']
    },
    langs: ['ru', 'en']
  },

Webpack 2

// setting for bem-loader
module: {
    rules: [
        {
            test : /\.react\.js$/,
            loader: 'webpack-bem-loader',
            options: {
                naming: 'react',
                levels: ['./pathToBlocks'],
                // OR:
                // levels: {
                //     './pathToBlocks': {
                //         default: true,
                //         scheme: 'nested',
                //         naming: 'origin'
                //     }
                // },
                techs: ['js', 'css'],
                techMap: {
                    js : ['react.js']
                },
                langs: ['ru', 'en']
            }
        }
    ]
}

Options

  • levels : Required option — paths to components declarations
  • naming: bem-naming overrides naming
  • techs : list of techs extensions for require in runtime, ['js'] by default. First tech will be default export
  • 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
  • generators : customization of code generators by tech. The function when it is provided receive one argument: files with signature Array<String>. This is the list of files of the specified technology, got from current import. Examples: { js : null } or { js: (files) => files.map(file => `require('${file.path}')`).join(',\n') }. Each generator must return String. Check ./generators for examples.

    i18n

    .i18n - represent special technology that provides the opportunity to localize components.

    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.js
    module.exports = {
        "Attach": {
            "button-text": "Dosya seç",
            "no-file": "dosya seçilmedi"
        }
    };

    inside Attach.js:

    import i18n from `b:Attach t:i18n`
    
    console.log(i18n('button-text')) // → Dosya seç

    webpack-bem-loader transpiles such code to

    var i18n = (function() {
        var core = require('/absolute-path-to/webpack-bem-loader/generators/i18n/core');
    
        if (process.env.BEM_LANG === 'ru') {
            return core().decl(require('../Attach.i18n/ru'))('Attach')
        }
    
        if (process.env.BEM_LANG === 'en') {
            return core().decl(require('../Attach.i18n/en'))('Attach')
        }
    
        if (process.env.BEM_LANG === 'tr') {
            return core().decl(require('../Attach.i18n/tr'))('Attach')
        }
    })();
    
    console.log(i18n('button-text')) // → Dosya seç

    process.env.BEM_LANG is need to be defined. ru, en and tr are taken from langs option.

    License MPL-2.0

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].