123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292 |
- import { AsyncSeriesWaterfallHook } from "tapable";
- import { Compiler, Compilation } from "webpack";
- import { Options as HtmlMinifierOptions } from "html-minifier-terser";
- export = HtmlWebpackPlugin;
- declare class HtmlWebpackPlugin {
- constructor(options?: HtmlWebpackPlugin.Options);
- userOptions: HtmlWebpackPlugin.Options;
- /** Current HtmlWebpackPlugin Major */
- version: number;
- /**
- * Options after html-webpack-plugin has been initialized with defaults
- */
- options?: HtmlWebpackPlugin.ProcessedOptions;
- apply(compiler: Compiler): void;
- static getHooks(compilation: Compilation): HtmlWebpackPlugin.Hooks;
- /**
- * Static helper to create a tag object to be get injected into the dom
- */
- static createHtmlTagObject(
- tagName: string,
- attributes?: { [attributeName: string]: string | boolean },
- innerHTML?: string
- ): HtmlWebpackPlugin.HtmlTagObject;
- static readonly version: number;
- }
- declare namespace HtmlWebpackPlugin {
- type MinifyOptions = HtmlMinifierOptions;
- interface Options {
-
- cache?: boolean;
-
- chunks?: "all" | string[];
-
- chunksSortMode?:
- | "auto"
-
- | "none"
- | "manual"
- | ((entryNameA: string, entryNameB: string) => number);
-
- excludeChunks?: string[];
-
- favicon?: false | string;
-
- filename?: string | ((entryName: string) => string);
-
- publicPath?: string | "auto";
-
- hash?: boolean;
-
- inject?:
- | false
- | true
- | "body"
- | "head";
-
- scriptLoading?: "blocking" | "defer" | "module" | "systemjs-module";
-
- meta?:
- | false
- | {
- [name: string]:
- | string
- | false
- | { [attributeName: string]: string | boolean };
- };
-
- minify?: "auto" | boolean | MinifyOptions;
-
- showErrors?: boolean;
-
- template?: string;
-
- templateContent?:
- | false
- | string
- | ((templateParameters: {
- [option: string]: any;
- }) => string | Promise<string>)
- | Promise<string>;
-
- templateParameters?:
- | false
- | ((
- compilation: Compilation,
- assets: {
- publicPath: string;
- js: Array<string>;
- css: Array<string>;
- manifest?: string;
- favicon?: string;
- },
- assetTags: {
- headTags: HtmlTagObject[];
- bodyTags: HtmlTagObject[];
- },
- options: ProcessedOptions
- ) => { [option: string]: any } | Promise<{ [option: string]: any }>)
- | { [option: string]: any };
-
- title?: string;
-
- xhtml?: boolean;
-
- [option: string]: any;
- }
-
- interface ProcessedOptions extends Required<Options> {
- filename: string;
- }
-
- interface TemplateParameter {
- compilation: Compilation;
- htmlWebpackPlugin: {
- tags: {
- headTags: HtmlTagObject[];
- bodyTags: HtmlTagObject[];
- };
- files: {
- publicPath: string;
- js: Array<string>;
- css: Array<string>;
- manifest?: string;
- favicon?: string;
- };
- options: Options;
- };
- webpackConfig: any;
- }
- interface Hooks {
- alterAssetTags: AsyncSeriesWaterfallHook<{
- assetTags: {
- scripts: HtmlTagObject[];
- styles: HtmlTagObject[];
- meta: HtmlTagObject[];
- };
- publicPath: string,
- outputName: string;
- plugin: HtmlWebpackPlugin;
- }>;
- alterAssetTagGroups: AsyncSeriesWaterfallHook<{
- headTags: HtmlTagObject[];
- bodyTags: HtmlTagObject[];
- outputName: string;
- publicPath: string,
- plugin: HtmlWebpackPlugin;
- }>;
- afterTemplateExecution: AsyncSeriesWaterfallHook<{
- html: string;
- headTags: HtmlTagObject[];
- bodyTags: HtmlTagObject[];
- outputName: string;
- plugin: HtmlWebpackPlugin;
- }>;
- beforeAssetTagGeneration: AsyncSeriesWaterfallHook<{
- assets: {
- publicPath: string;
- js: Array<string>;
- css: Array<string>;
- favicon?: string;
- manifest?: string;
- };
- outputName: string;
- plugin: HtmlWebpackPlugin;
- }>;
- beforeEmit: AsyncSeriesWaterfallHook<{
- html: string;
- outputName: string;
- plugin: HtmlWebpackPlugin;
- }>;
- afterEmit: AsyncSeriesWaterfallHook<{
- outputName: string;
- plugin: HtmlWebpackPlugin;
- }>;
- }
-
- interface HtmlTagObject {
-
- attributes: {
- [attributeName: string]: string | boolean | null | undefined;
- };
-
- tagName: string;
-
- innerHTML?: string;
-
- voidTag: boolean;
-
- meta: {
- plugin?: string,
- [metaAttributeName: string]: any;
- };
- }
- }
|