On this page

class webpack.HtmlParser extends Parser

Defines the parser state base type used by this module.

new HtmlParser(): HtmlParser
Returns:HtmlParser
Attributes
fragmentContext:string
magicCommentContext:Context
sourcesByTag:SourceTable
template:(source: string, context: HtmlTemplateContext) => string
applyTemplate(source, module): string | Buffer<ArrayBufferLike>
Attributes
source:string | Buffer<ArrayBufferLike>
Returns:string | Buffer<ArrayBufferLike>

Runs the template option over the source and returns the transformed html. Called from HtmlModulesPlugin's processResult, where the return value becomes the module's stored source so the parser (which records dependency offsets against it) and the generator (which renders from module.originalSource()) stay in agreement.


parse(source, state): ParserState
Attributes
source:string | Buffer<ArrayBufferLike> | PreparsedAst
Returns:ParserState

Parses the provided source and updates the parser state.


Attributes
filter:(attributes: Map<string, string>, value: string) => boolean
namespace:number


Type:"html" | "script" | "css-url" | "stylesheet" | "prefetch" | "preload" | "modulepreload" | "script-module" | "src" | "srcset" | "stylesheet-style" | "stylesheet-style-attribute" | "srcdoc" | "msapplication-task"

Type:"html" | "script" | "css-url" | "stylesheet" | "prefetch" | "preload" | "modulepreload" | "script-module" | "src" | "srcset" | "stylesheet-style" | "stylesheet-style-attribute" | "srcdoc" | "msapplication-task" | ((attrs: Map<string, string>, css: boolean) => SourceType)