3.0.0 • Published 4 months ago

event-hooks-webpack-plugin v3.0.0

Weekly downloads
18,818
License
MIT
Repository
github
Last release
4 months ago

Event Hooks Webpack Plugin

npm npm license

This Webpack plugin is similar to webpack-shell-plugin but it allows executing arbitrary code instead of commands on any compiler hook that is made available by Webpack.

Installation

npm install event-hooks-webpack-plugin --save-dev

Usage

import EventHooksPlugin from 'event-hooks-webpack-plugin';

module.exports = {
    // ...
    plugins: [
        new EventHooksPlugin({
            initialize: () => {
                // ...
            }
        })
    ]
};

Options

The plugin consumes an object with Webpack compiler event hook names (e.g. run, compile, and done) as keys and functions as values.

Tapable

Webpack's compiler uses Tapable which supports different classes of hooks. This plugin supports synchronous, promise-based, and callback-based hooks through the exported tap, tapPromise and tapAsync methods. By default, the plugin uses tap.

import EventHooksPlugin, { tapPromise, tapAsync } from 'event-hooks-webpack-plugin';

module.exports = {
    // ...
    plugins: [
        new EventHooksPlugin({
            emit: tapAsync(() => {
                // ...
            }),
            run: tapPromise(() => {
                // ...
            })
        })
    ]
};

License

This project is licensed under the MIT license.