https://github.com/cascornelissen/event-hooks-webpack-plugin
Event hooks plugin for webpack
https://github.com/cascornelissen/event-hooks-webpack-plugin
event-hooks webpack webpack-plugin
Last synced: 2 months ago
JSON representation
Event hooks plugin for webpack
- Host: GitHub
- URL: https://github.com/cascornelissen/event-hooks-webpack-plugin
- Owner: cascornelissen
- License: mit
- Created: 2017-04-01T18:19:20.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2025-03-22T03:34:33.000Z (3 months ago)
- Last Synced: 2025-03-29T06:08:26.128Z (2 months ago)
- Topics: event-hooks, webpack, webpack-plugin
- Language: TypeScript
- Homepage:
- Size: 2.08 MB
- Stars: 34
- Watchers: 1
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Event Hooks Webpack Plugin
[](https://www.npmjs.com/package/event-hooks-webpack-plugin)
[](https://www.npmjs.com/package/event-hooks-webpack-plugin)
[](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