Skip to content

felixhao28/event-hooks-webpack-plugin

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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');
const { CallbackTask } = require('event-hooks-webpack-plugin/lib/tasks');

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

Promises

const EventHooksPlugin = require('event-hooks-webpack-plugin');
const { PromiseTask } = require('event-hooks-webpack-plugin/lib/tasks');

module.exports = {
    // ...
    plugins: [
        new EventHooksPlugin({
            eventName: new 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.

About

Event hooks plugin for webpack

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%