Skip to content
This repository has been archived by the owner on Mar 25, 2018. It is now read-only.

gulp-bem/gulp-bem-bundle-builder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

34 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gulp-bem-bundle-builder

DEPRECATED repository, moved to mono repository gulp-bem

Easy to use builder for streams of BemBundle and Vinyl objects;

Install

npm i gulp-bem-bundle-builder

Usage

const concat = require('gulp-concat');
const bundlerFs = require('gulp-bem-bundler-fs'); // Read bundles from FS by glob
const bundleBuilder = require('gulp-bem-bundle-builder');

// Create an instance with configuration to run typical build tasks
const builder = bundleBuilder({
    config: {
        levels: {
            'libs/super-library/blocks': {scheme: 'nested'},
            'blocks': {scheme: 'nested'}
        }
    },
    levels: [
        'libs/super-library/blocks',
        'blocks'
    ],
    techMap: {
        js: ['vanilla.js', 'browser.js', 'js'],
        css: ['styl', 'css']
    }
});

bundlerFs('bundles/*')
    .pipe(builder({
        css: bundle => bundle.src('css').pipe(concat('file.css')),
        js: bundle => bundle.src('js').pipe(concat('file.js'))
    }))
    .pipe(...) // Stream<Vinyl>
    .pipe(gulp.dest('.'));

API

BundleBuilder

BundleBuilder({
    config: ?BemConfig,          // BEM-project configuration
    levels: ?String[],           // Levels to use for building by default
    techMap: ?Object             // Mapping deps to file tech
}):
    function(Object<tech: String, function(bundle: BundleBuilder~Bundle): Stream<Vinyl>>):
        TransformStream<Vinyl|BemBundle, Vinyl>

BundleBuilder~Bundle

BemBundle class extended by src and target helper methods.

BundleBuilder~Bundle.src

Gather vinyl file objects that responde to BEM entity declaration and their dependencies and return them as a readable stream.

Bundle.src(tech: String, opts: ?Object): Stream<Vinyl>

BundleBuilder~Bundle.target

Returns resulting stream of a target.

Bundle.target(target: String): Stream<Vinyl>

NB: Beware of cycles:

builder({
    a: bundle => bundle.target('b'),
    b: bundle => bundle.target('a')
});

License

Code and documentation copyright 2016 YANDEX LLC. Code released under the Mozilla Public License 2.0.