# event-hooks-webpack-plugin

> Execute JavaScript on any available Webpack event hook

Latest version **3.1.0** (published 2026-04-27) · MIT license · 0 weekly downloads

## Install

```sh
npm install event-hooks-webpack-plugin
pnpm add event-hooks-webpack-plugin
yarn add event-hooks-webpack-plugin
bun add event-hooks-webpack-plugin
```

## Health

**Score 65/100 (B)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2026-04-27 |
| First published | 2017-04-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | ^20.11.0 \|\| ^21.2.0 \|\| >=22.16.0 |
| Dependencies | 0 |
| Unpacked size | 12.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 35 |
| Author | Cas Cornelissen |
| Maintainers | cascornelissen |
| Keywords | event, hook, webpack, plugin |

## Links

- npm: https://www.npmjs.com/package/event-hooks-webpack-plugin
- Repository: https://github.com/cascornelissen/event-hooks-webpack-plugin
- Homepage: https://github.com/cascornelissen/event-hooks-webpack-plugin#readme
- Issues: https://github.com/cascornelissen/event-hooks-webpack-plugin/issues
- npm.io page: https://npm.io/package/event-hooks-webpack-plugin

## Alternatives

- [async-exit-hook](https://npm.io/package/async-exit-hook.md) — 3.7M weekly downloads
- [evnty](https://npm.io/package/evnty.md) — 7.2K weekly downloads
- [eleventy-plugin-asciidoc](https://npm.io/package/eleventy-plugin-asciidoc.md) — 3.5K weekly downloads
- [@jswork/next-get2get](https://npm.io/package/@jswork/next-get2get.md) — 945 weekly downloads
- [@dashersw/axon](https://npm.io/package/@dashersw/axon.md) — 934 weekly downloads

## Recent versions

- 3.1.0 (latest) — 2026-04-27
- 3.0.1 — 2025-03-17
- 3.0.0 — 2025-02-26
- 2.3.0 — 2023-03-23
- 2.2.0 — 2020-11-02
- 2.1.7 — 2020-07-18
- 2.1.6 — 2020-03-14
- 2.1.5 — 2019-12-14
- 2.1.4 — 2019-07-16
- 2.1.3 — 2019-07-16
- 2.1.2 — 2019-06-20
- 2.1.1 — 2018-11-07
- 2.1.0 — 2018-08-21
- 2.0.0 — 2018-03-12
- 2.0.0-rc.1 — 2018-03-04
- … 1 more at https://npm.io/package/event-hooks-webpack-plugin/versions

## README

# Event Hooks Webpack Plugin
[![npm](https://img.shields.io/npm/v/event-hooks-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/event-hooks-webpack-plugin)
[![npm](https://img.shields.io/npm/dm/event-hooks-webpack-plugin.svg?style=flat-square)](https://www.npmjs.com/package/event-hooks-webpack-plugin)
[![license](https://img.shields.io/github/license/cascornelissen/event-hooks-webpack-plugin.svg?style=flat-square)](LICENSE.md)

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

## Installation
```shell
npm install event-hooks-webpack-plugin --save-dev
```

## Usage
```js
import EventHooksPlugin from 'event-hooks-webpack-plugin';

export default {
    // ...
    plugins: [
        new EventHooksPlugin({
            initialize: () => {
                // ...
            }
        })
    ]
};
```

## Options
The plugin consumes an object with [Webpack compiler event hook names][webpack-compiler-hooks] (e.g. `run`, `compile`,
and `done`) as keys and functions as values.

### Tapable
Webpack's compiler uses [Tapable][webpack-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`.

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

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

## License
This project is [licensed](LICENSE.md) under the [MIT][mit-license] license.



[webpack]: https://webpack.github.io/
[webpack-tapable]: https://github.com/webpack/tapable#tapable
[webpack-shell-plugin]: https://www.npmjs.com/package/webpack-shell-plugin
[webpack-compiler-hooks]: https://webpack.js.org/api/compiler-hooks/
[mit-license]: https://opensource.org/licenses/MIT

---
_Source: https://npm.io/package/event-hooks-webpack-plugin · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
