gulp-bem-bundle-builder

0.1.5 • Public • Published

gulp-bem-bundle-builder

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

NPM Status Travis Status Coverage Status Dependency Status

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.

Readme

Keywords

Package Sidebar

Install

npm i gulp-bem-bundle-builder

Weekly Downloads

6

Version

0.1.5

License

MPL-2.0

Last publish

Collaborators

  • blond
  • qfox