Package Exports
- event-hooks-webpack-plugin
- event-hooks-webpack-plugin/lib/tasks
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (event-hooks-webpack-plugin) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Event Hooks Webpack Plugin
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.
Compatibility
Version ^2.0.0
of this plugin is compatible with webpack ^4.0.0
. If you're using an older version of webpack, make sure to install the ^1.0.0
(npm install event-hooks-webpack-plugin@^1.0.0
) release of this plugin.
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.