new HtmlModulesPlugin(): HtmlModulesPluginReturns:
HtmlModulesPluginAttributes
getCompilationHooks:
(compilation: Compilation) => HtmlCompilationHooksPer-compilation hooks for the experimental HTML support.
apply(compiler): voidAttributes
Applies the plugin by registering its hooks on the compiler.
Attributes
output.hashFunction/hashSalt/hashDigest/hashDigestLength
digest of content, with nonNumericOnlyHash applied — webpack's
standard [contenthash] recipe.
Attributes
chunk:
Chunkchunk
outputOptions:
Outputoutput options
Returns:
ChunkFilenameTemplateused 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 hashedtransformHtml:
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
defer
↔
async
, …), 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
insteadAttributes
outputName:
stringAttributes
Attributes
mutable attributes; a string value renders
name="value"
,
true
a bare attribute,
false
/
undefined
/deleting the key drops itinjectTo:
"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:
booleanset true to delete the whole element
tag:
stringthe (lowercased) tag name
Attributes
attributes;
true
renders a bare boolean attribute,
false
/
undefined
is omittedchildren:
stringinner content (ignored for void elements like
<link>
/
<meta>
)injectTo:
"body" | "head" | "head-prepend" | "body-prepend"placement; defaults to
"head"tag:
stringtag name, e.g.
"script"
/
"link"
/
"meta"voidTag:
booleanforce a void element (no closing tag); inferred from the tag name when omitted
Attributes
outputName:
stringAttributes