Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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: 19 days 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 (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-09-05T20:52:22.000Z (2 months ago)
- Last Synced: 2024-10-13T20:12:18.558Z (about 1 month ago)
- Topics: event-hooks, webpack, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 1.84 MB
- Stars: 34
- Watchers: 2
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
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](https://webpack.github.io/) plugin is similar to [`webpack-shell-plugin`](https://www.npmjs.com/package/webpack-shell-plugin) but this allows you to execute arbitrary JavaScript instead of commands on *any* [event hook](https://webpack.js.org/api/compiler-hooks/) that is exposed by the Webpack compiler.
## Installation
```shell
npm install event-hooks-webpack-plugin --save-dev
```## Synchronous usage
```js
const EventHooksPlugin = require('event-hooks-webpack-plugin');module.exports = {
// ...
plugins: [
new EventHooksPlugin({
eventName: () => {
// ...
}
})
]
};
```## Asynchronous usage
### Callbacks
```js
const EventHooksPlugin = require('event-hooks-webpack-plugin');module.exports = {
// ...
plugins: [
new EventHooksPlugin({
eventName: new EventHooksPlugin.CallbackTask((compiler, callback) => {
// ...
callback();
})
})
]
};
```### Promises
```js
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](https://github.com/webpack/webpack/blob/214b06645ac182b7f0c68319e35445e02541d957/lib/Compiler.js#L119) (e.g. `run`, `compile`, or `done`) as keys and functions or [task classes](./lib/tasks.js) as values.## License
This project is [licensed](LICENSE.md) under the [MIT](https://opensource.org/licenses/MIT) license.