On this page

new HtmlModulesPlugin(): HtmlModulesPlugin
Attributes
getCompilationHooks:(compilation: Compilation) => HtmlCompilationHooks
Per-compilation hooks for the experimental HTML support.
apply(compiler): void
Attributes
compiler:Compiler
the compiler instance
Returns:void

Applies the plugin by registering its hooks on the compiler.


Attributes
content:string | Buffer<ArrayBufferLike>
content to hash
outputOptions:Output
output options
Returns:string
content hash

output.hashFunction/hashSalt/hashDigest/hashDigestLength digest of content, with nonNumericOnlyHash applied — webpack's standard [contenthash] recipe.


Attributes
chunk:Chunk
chunk
outputOptions:Output
output options
used filename template

Filename template for an extracted HTML page: output.htmlFilename for initial chunks, output.htmlChunkFilename otherwise — the HTML counterpart of CssModulesPlugin.getChunkFilenameTemplate.

Attributes
htmlEmitted:AsyncSeriesHook<[HtmlEmittedContext]>
called once each page's HTML asset has been finalized — a post-emit notification (nothing to return)
injectTags:AsyncSeriesWaterfallHook<[HtmlTagDescriptor[], HtmlInjectTagsContext], HtmlTagDescriptor[]>
called with the list of extra tags to inject into each page (initially empty) plus the current HTML; push HtmlTagDescriptor s and return the list — webpack serializes and places them by injectTo . A structured alternative to the string-level transformHtml for adding tags; runs before CSP so injected inline tags are hashed
transformHtml:AsyncSeriesWaterfallHook<[string, HtmlTransformHtmlContext], string>
called with each emitted page's final HTML (all sentinels resolved) just before it is written; return the (possibly transformed) HTML — e.g. to minify, inject a CSP meta, or rewrite tags
transformTags:AsyncSeriesHook<[HtmlMutableTag[], HtmlTransformTagsContext]>
called with the page's <script> / <link> / <style> / <meta> tags (webpack's own and any injected) as mutable descriptors; mutate attrs (add a nonce / data-* , switch deferasync , …), set remove: true , or change injectTo to move a tag between <head> and <body> , and webpack rewrites the changed tags. Add new tags with injectTags instead

Attributes
outputName:string

Attributes
html:string
outputName:string

Attributes
attrs:Record<string, undefined | string | boolean>
mutable attributes; a string value renders name="value" , true a bare attribute, false / undefined /deleting the key drops it
injectTo:"body" | "head" | "head-prepend" | "body-prepend"
the tag's current region ( "head" / "body" ); set a different value to move it there ( *-prepend to the region's start)
remove:boolean
set true to delete the whole element
tag:string
the (lowercased) tag name

Attributes
attrs:Record<string, string | boolean | undefined>
attributes; true renders a bare boolean attribute, false / undefined is omitted
children:string
inner content (ignored for void elements like <link> / <meta> )
injectTo:"body" | "head" | "head-prepend" | "body-prepend"
placement; defaults to "head"
tag:string
tag name, e.g. "script" / "link" / "meta"
voidTag:boolean
force a void element (no closing tag); inferred from the tag name when omitted

Attributes
outputName:string

Attributes
html:string
outputName:string