Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alexispuga/hook-webpack-plugin
Create, intercept and/or extend the functionality of any plugin by using hooks from your config file.
https://github.com/alexispuga/hook-webpack-plugin
circle-ci coveralls eslint github-wiki jsdoc-comments npm-package webpack-plugin
Last synced: about 1 month ago
JSON representation
Create, intercept and/or extend the functionality of any plugin by using hooks from your config file.
- Host: GitHub
- URL: https://github.com/alexispuga/hook-webpack-plugin
- Owner: AlexisPuga
- License: mit
- Created: 2019-10-06T04:21:07.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-03-15T01:17:26.000Z (almost 2 years ago)
- Last Synced: 2024-11-14T16:54:20.149Z (about 1 month ago)
- Topics: circle-ci, coveralls, eslint, github-wiki, jsdoc-comments, npm-package, webpack-plugin
- Language: JavaScript
- Homepage:
- Size: 440 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
## Hook - webpack plugin
**Create** custom plugins from your config file and avoid loosing time finding or maintaining a simple plugin.
**Intercept** any plugin and customize it to match your preferences.
**Group** your hooks to create a new plugin and modify it when you want.
## Contents
- [Installation](#installation)
- [Usage](#usage)
- [Examples](#examples)
- [Creating a plugin](#creating-a-plugin)
- [Registering a plugin](#registering-a-plugin)
- [Intercepting another plugin](#intercepting-another-plugin)
- [More info](#more-info)
- [License](#license)## Installation
**Via npm:**
```
npm i hook-webpack-plugin
```**Via yarn:**
```
yarn add hook-webpack-plugin --dev
```## Usage
Add something like the following to your config file, in the plugin section:
```js
// webpack.config.js
const HookWebpackPlugin = require('hook-webpack-plugin');// ...
plugins: [
// ...
new HookWebpackPlugin(hookName, hookFn, options)
// ...
]
// ...```
Then, replace the following values:
-
hookName: string - The name of a compiler/compilation hook. Something like "emit", "done", ...
-
hookFn: function - The listener for the hook.
-
options: objectopt -
Property
Default
Description
sync
false [async when possible]
If a truthy value is given use `tap`, otherwise use `tapAsync`.
pluginName
HookWebpackPlugin
Value to use in tap/tapAsync methods.
## Examples
### Creating a plugin
```js
// webpack.config.js
plugins: [
new HookWebpackPlugin(hookName, compilerHook (...args) {
// Do something awesome...
})
]
```
### Registering a plugin
*Name your plugin and group multiple hooks together, internally.*
```js
// webpack.config.js
plugins: [
new HookWebpackPlugin(hookName, compilerHook, {pluginName: 'MyAwesomePlugin'}),
new HookWebpackPlugin(anotherHookName, anotherCompilerHook, {pluginName: 'MyAwesomePlugin'})
]
```
### Intercepting another plugin
*Set the `pluginName` option to the internal name of the plugin you want to intercept.*
```js
// webpack.config.js
plugins: [
new ThirdPartyPlugin(options),
new HookWebpackPlugin(hookName, () => {
// Your code...
}, {'pluginName': 'ThirdPartyPlugin'})
]
```
## More info
Check the [docs](https://github.com/AlexisPuga/hook-webpack-plugin/wiki) for more details.
## License
hook-webpack-plugin is [MIT licensed](./LICENSE).