1. event-hooks-webpack-plugin
Execute JavaScript on any available Webpack event hook
event-hooks-webpack-plugin
Package: event-hooks-webpack-plugin
Created by: cascornelissen
Last modified: Thu, 23 Mar 2023 19:08:01 GMT
Version: 2.3.0
License: MIT
Downloads: 54,060
Repository: https://github.com/cascornelissen/event-hooks-webpack-plugin

Install

npm install event-hooks-webpack-plugin
yarn add event-hooks-webpack-plugin

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.

RELATED POST

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Enhancing Vue.js Development: Harnessing the Potential of Vue-Loader

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Simplify Data Validation in Vue.js: A Step-by-Step Guide to Using Regex

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Troubleshooting Made Easy: Common Issues and Solutions with vue-loader Without vue-cli

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Optimizing Webpack 4 with Vue CLI 3: Disabling the Cache-Loader

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin

Step-by-Step Guide: How to Add a Function to Your Vuex Plugin