1.1.0 • Published 3 years ago

hook-webpack-plugin v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

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

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:

// webpack.config.js
const HookWebpackPlugin = require('hook-webpack-plugin');

// ...
plugins: [
    // ...
    new HookWebpackPlugin(hookName, hookFn, options)
    // ...
]
// ...

Then, replace the following values:

Examples

Creating a plugin

// webpack.config.js

plugins: [
    new HookWebpackPlugin(hookName, compilerHook (...args) {
        // Do something awesome...
    })
]

Registering a plugin

Name your plugin and group multiple hooks together, internally.

// 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.

// webpack.config.js

plugins: [
    new ThirdPartyPlugin(options),
    new HookWebpackPlugin(hookName, () => {
        // Your code...
    }, {'pluginName': 'ThirdPartyPlugin'})
]

More info

Check the docs for more details.

License

hook-webpack-plugin is MIT licensed.

1.1.0

3 years ago

1.0.1

5 years ago

1.0.0

5 years ago

1.0.0-rc.2

5 years ago