-
Notifications
You must be signed in to change notification settings - Fork 0
HookWebpackPlugin
This content was generated from the documentation written here.
- HookWebpackPlugin
-
A hook injector for Webpack config.
-
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.
A hook injector for Webpack config.
Kind: global class
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.
]
Use tap
or tapAsync
to inject a hook during the compilation process.
Kind: instance method of HookWebpackPlugin
Chainable
Param | Type |
---|---|
webpackContext |
Compiler | Compilation
|
hookFn : hookFn
options : options
Options for HookWebpackPlugin.
Kind: global typedef
Properties
Name | Type | Default |
---|---|---|
[sync] | boolean |
false |
[pluginName] | string |
"HookWebpackPlugin" |
The listener for the hook.
Kind: global typedef
this: HookWebpackPlugin
Param | Type | Description |
---|---|---|
...args | * |
The hook arguments. |
A valid compiler/compilation hook, like "done"... See:
Keep in mind that compilation hooks are expected to be inside a compiler hook.The Compiler or Compilation instance from Webpack.
Kind: global typedef