event-hooks-webpack-plugin
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/event-hooks-webpack-plugin package

2.3.0 • Public • Published

Event Hooks Webpack Plugin

npm npm license

This webpack plugin is similar to webpack-shell-plugin but this allows you to execute arbitrary JavaScript instead of commands on any event hook that is exposed by the Webpack compiler.

Installation

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

Synchronous usage

const EventHooksPlugin = require('event-hooks-webpack-plugin');

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

Asynchronous usage

Callbacks

const EventHooksPlugin = require('event-hooks-webpack-plugin');

module.exports = {
    // ...
    plugins: [
        new EventHooksPlugin({
            eventName: new EventHooksPlugin.CallbackTask((compiler, callback) => {
                // ...
                callback();
            })
        })
    ]
};

Promises

const EventHooksPlugin = require('event-hooks-webpack-plugin');

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

Options

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

License

This project is licensed under the MIT license.

Package Sidebar

Install

npm i event-hooks-webpack-plugin

Weekly Downloads

10,199

Version

2.3.0

License

MIT

Unpacked Size

6.7 kB

Total Files

6

Last publish

Collaborators

  • cascornelissen