0.0.8 • Published 2 years ago

@spearhook/spearhook v0.0.8

Weekly downloads
13
License
MIT
Repository
-
Last release
2 years ago

Spearhook

A minimal, pluggable, non-bundling web app pipeline.

Why non-bundling?

Some projects need an easy pipeline for AMD or other fully-split formats, without having to fight against a bundler.

Usage

Install, via yarn yarn add --dev @spearhook/spearhook or NPM npm install --save-dev @spearhook/spearhook.

Add a spearhook.config.js file to the root of your project.

Configure a list of files and plugins to flow them through:

export default {
    input: 'src/app.js',
    plugins: [
        babel({
            presets: ['@babel/preset-env']
        }),
        writer((filepath) => filepath.replace('src', 'dist'))
    ]
};

Run spearhook.

Writing Plugins

Create a new javascript file which exports a module.

Each plugin has three core pieces:

  1. The initialization function, in which custom configuration options are provided.
  2. A stream execution function, which returns a stream transformer.
  3. File contents/path actor.
import through2 from 'through2';

export default function(opts) {
    return () => through2.obj(function(file, encoding, cb) {
        // transform file.contents, act on file.path, etc

        // emit errors with this.emit('spearhook.error', ...);

        cb(null, file);
    });
};

The file argument is a Vinyl File object.

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

5 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago