CC 4.0 License

The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.

The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.

Plugin API

Stability: Experimental
Webpack Plugin API conformance

Check out this page to see the status of Webpack Plugin API conformance.

Compiler Hooks

environment

SyncHook<[]>

Called while preparing the compiler environment, right after initializing the plugins in the configuration file.

afterEnvironment

SyncHook<[]>

Called right after the environment hook, when the compiler environment setup is complete.

afterPlugins

SyncHook<[Compiler]>

Called after setting up initial set of internal plugins.

afterResolvers

SyncHook<[Compiler]>

Triggered after resolver setup is complete.

entryOption

SyncBailHook<[string, EntryNormalized]>

Called after the entry configuration has been processed.

initialize

SyncHook<[]>

Called when a compiler object is initialized.

beforeRun

AsyncSeriesHook<[Compiler]>

Adds a hook right before running the compiler.

run

AsyncSeriesHook<[Compiler]>

Called at the beginning of a build execution.

childCompiler

SyncHook[Compiler, string, number]

where the version of the function type is >=0.4.1.

Executed after created a childCompiler.

watchRun

AsyncSeriesHook<[Compiler]>

Executes a plugin during watch mode after a new compilation is triggered but before the compilation is actually started.

compile

SyncHook<[]>

Called right after beforeCompile, before a new compilation is created.

beforeCompile

AsyncSeriesHook<[]>

Executes a plugin after compilation parameters are created.

afterCompile

AsyncSeriesHook<[Compilation]>

Called after finishing and sealing the compilation.

thisCompilation

SyncHook<[Compilation]>

Executed while initializing the compilation, right before emitting the compilation event.

compilation

SyncHook<[Compilation]>

Runs a plugin after a compilation has been created.

make

AsyncParallelHook<[Compilation]>

Executed before the make stage.

shouldEmit

SyncBailHook<[Compilation]>

where the version of the function type is >=0.4.1.

Return a boolean telling whether to emit.

emit

AsyncSeriesHook<[Compilation]>

Executed right before emitting assets to output directory.

afterEmit

AsyncSeriesHook<[Compilation]>

Called after emitting assets to output directory.

done

AsyncSeriesHook<Stats>

Executed when the compilation has completed.

afterDone

AsyncSeriesHook<Stats>

Executed after done hook.

watchClose

SyncHook<[]>

Called when a watching compilation has stopped.

failed

SyncHook<[Error]>

Called if the compilation fails.

Compilation Hooks

buildModule

SyncHook<[JsModule]>

Triggered before a module build has started, can be used to modify the module (Rspack currently only support reading the module, modifying is not supported yet).

processAssets

AsyncSeriesHook<[CompilationAssets]>

Process the assets before emit.

optimizeModules

SyncBailHook<[JsModule[]]>

Called at the beginning of the module optimization phase. A plugin can tap into this hook to perform optimizations on modules.

optimizeChunkModule

AsyncSeriesBailHook<[JsModule[]]>

Called after the tree optimization, at the beginning of the chunk modules optimization. A plugin can tap into this hook to perform optimizations of chunk modules.

succeedModule

SyncHook<[JsModule]>

Executed when a module has been built successfully.

finishModules

AsyncSeriesHook<[JsModule[]]>

Called when all modules have been built without errors.

chunkAsset

SyncHook<[JsChunk[], string /** filename*/ ]>

Triggered when an asset from a chunk was added to the compilation.

NormalModuleFactory

beforeResolve

AsyncSeriesBailHook<[ResolveData]>

Called when a new dependency request is encountered. A dependency can be ignored by returning false. Otherwise, it should return undefined to proceed.

afterResolve

AsyncSeriesBailHook<[ResolveData]>

Called after the request is resolved.

ResolveForScheme

AsyncSeriesBailHook<[ResourceDataWithData]>

Called before a request with scheme (URI) is resolved.

ContextModuleFactory

afterResolve

AsyncSeriesBailHook<[ResolveData]>

Called after the requested directory resolved.