Compiler module is the main engine that creates a compilation instance with all the options passed through the webpack configuration. It extends Tapable and provides lifecycle hooks.
Accessing Compiler Hooks
Compiler hooks are accessed in your plugin’sapply method:
Hook Types Reference
Each hook is an instance of a Tapable hook class. The type determines how you can tap into it:SyncHook- Use.tap()onlySyncBailHook- Use.tap(), can return value to exit earlyAsyncSeriesHook- Use.tap(),.tapAsync(), or.tapPromise()AsyncParallelHook- Use.tap(),.tapAsync(), or.tapPromise()(runs in parallel)
Lifecycle Hooks
initialize
environment
afterEnvironment
afterPlugins
afterResolvers
entryOption
true to prevent default entry processing.
Build Lifecycle Hooks
beforeRun
run
watchRun
Compilation Hooks
beforeCompile
compile
thisCompilation
compilation hook.
compilation
make
finishMake
afterCompile
Module Factory Hooks
normalModuleFactory
contextModuleFactory
Emit Hooks
shouldEmit
false to prevent emitting assets.
emit
assetEmitted
afterEmit
Completion Hooks
done
afterDone
done hook completes.
failed
Watch Mode Hooks
invalid
watchClose
Other Hooks
shutdown
infrastructureLog
Complete Example
See Also
- Compilation Hooks - Hooks for the compilation phase
- Module Factories - Module creation hooks
- Tapable - Understanding the hook system