unlight / fusebox-gulp-plugin

Adapt gulp plugins to work with fuse-box
3 stars 0 forks source link
fusebox

fusebox-gulp-plugin

Adapt gulp plugins to work with fuse-box.

Usage

const fsbx = require('fuse-box');
const g = require('gulp-load-plugins')();
const { GulpPlugin } = require('fusebox-gulp-plugin');

const fuseBox = fsbx.FuseBox.init({
    homeDir: 'src/',
    outFile: './build/app.js',
    plugins: [
        // Other fusebox plugins...
        GulpPlugin([
            (file) => g.replace('foo', 'bar'),
            // Other gulp plugins...
        ])
    ]
});

Note: GulpPlugin is applicable to all files, so you must control type of transform by ChainPlugin (see examples below).

Also, you can use only those plugins which only manipulates contents property of vinyl file.
Applying of some plugins, like gulp-rename, does not make sense, because they do not affect contents, but others - path, dirname, etc.

API

function GulpPlugin(streamFactories: ((file: File) => stream.Transform)[])

Examples

const { GulpPlugin } = require('fusebox-gulp-plugin');
const g = require('gulp-load-plugins')();

Markdown

const plugins = [
    [
        /\.md$/,
        GulpPlugin([
            () => g.markdown(),
        ]),
        RawPlugin({ extensions: ['.md'] }),
    ]
];
var doc = require('./doc.md')

JSON5

const plugins = [
    {
        init: (k) => k.allowExtension('.json5')
    },
    [
        /\.json5$/,
        GulpPlugin([
            () => g.json5(),
        ]),
        JSONPlugin({}),
    ]
];
const data = require('./data.json5');

DEBUG

inspect node_modules/ava/profile.js lib/index.spec.js