Skip to content

HookWebpackPlugin

Alexis Puga Ruíz edited this page Oct 13, 2019 · 1 revision

This content was generated from the documentation written here.

Classes

HookWebpackPlugin

A hook injector for Webpack config.

Members

hookName : string
hookFn : hookFn
options : options

Typedefs

options : object

Options for HookWebpackPlugin.

hookFn : function

The listener for the hook.

hookName : string

A valid compiler/compilation hook, like "done"... See:

Keep in mind that compilation hooks are expected to be inside a compiler hook.
webpackContext : Compiler | Compilation

The Compiler or Compilation instance from Webpack.

HookWebpackPlugin

A hook injector for Webpack config.

Kind: global class

new HookWebpackPlugin(hookName, hookFn, [opts])

Param Type Description
hookName hookName The name of a compiler/compilation hook.
hookFn hookFn The listener for the hook.
[opts] options Some options.

Example (Using compiler hooks)

// webpack.config.js
plugins: [
    new HookWebpackPlugin('shouldEmit', function compilerHook (compilation) {
        return false;
    }),
    new HookWebpackPlugin('emit', function compilerHook (compilation) {
        // Never got called.
    })
]

Example (Using compilation hooks)

// webpack.config.js
plugins: [
    new HookWebpackPlugin('emit', function compilerHook (compilation) {
        new HookWebpackPlugin('seal', function compilationHook (module) {
            // ...
        }).apply(compilation);
    })
]

Example ([Beta] Intercepting another plugin)

// webpack.config.js
plugins: [
    new HookWebpackPlugin('shouldEmit', () => false, {'pluginName': 'ThirdPartyPlugin'}),
    new ThirdPartyPlugin(options) // Never emitted.
]

hookWebpackPlugin.apply(webpackContext) ↩︎

Use tap or tapAsync to inject a hook during the compilation process.

Kind: instance method of HookWebpackPlugin
Chainable

Param Type
webpackContext Compiler | Compilation

hookName : string

Kind: global variable

hookFn : hookFn

Kind: global variable

options : options

Kind: global variable

options : object

Options for HookWebpackPlugin.

Kind: global typedef
Properties

Name Type Default
[sync] boolean false
[pluginName] string "HookWebpackPlugin"

hookFn : function

The listener for the hook.

Kind: global typedef
this: HookWebpackPlugin

Param Type Description
...args * The hook arguments.

hookName : string

A valid compiler/compilation hook, like "done"... See:

Keep in mind that compilation hooks are expected to be inside a compiler hook.

Kind: global typedef

webpackContext : Compiler | Compilation

The Compiler or Compilation instance from Webpack.

Kind: global typedef