export = HtmlMinimizerPlugin; /** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ /** @typedef {import("webpack").Compiler} Compiler */ /** @typedef {import("webpack").Compilation} Compilation */ /** @typedef {import("webpack").WebpackError} WebpackError */ /** @typedef {import("webpack").Asset} Asset */ /** @typedef {import("jest-worker").Worker} JestWorker */ /** @typedef {import("./utils.js").HtmlMinifierTerserOptions} HtmlMinifierTerserOptions */ /** @typedef {RegExp | string} Rule */ /** @typedef {Rule[] | Rule} Rules */ /** * @typedef {Object} MinimizedResult * @property {string} code * @property {Array} [errors] * @property {Array} [warnings] */ /** * @typedef {{ [file: string]: string }} Input */ /** * @typedef {{ [key: string]: any }} CustomOptions */ /** * @template T * @typedef {T extends infer U ? U : CustomOptions} InferDefaultType */ /** * @template T * @typedef {InferDefaultType | undefined} MinimizerOptions */ /** * @template T * @callback MinimizerImplementation * @param {Input} input * @param {MinimizerOptions} [minimizerOptions] * @returns {Promise} */ /** * @template T * @typedef {Object} Minimizer * @property {MinimizerImplementation} implementation * @property {MinimizerOptions | undefined} [options] */ /** * @template T * @typedef {Object} InternalOptions * @property {string} name * @property {string} input * @property {T extends any[] ? { [P in keyof T]: Minimizer; } : Minimizer} minimizer */ /** * @typedef InternalResult * @property {string} code * @property {Array} warnings * @property {Array} errors */ /** * @template T * @typedef {JestWorker & { transform: (options: string) => InternalResult, minify: (options: InternalOptions) => InternalResult }} MinimizerWorker */ /** * @typedef {undefined | boolean | number} Parallel */ /** * @typedef {Object} BasePluginOptions * @property {Rules} [test] * @property {Rules} [include] * @property {Rules} [exclude] * @property {Parallel} [parallel] */ /** * @template T * @typedef {BasePluginOptions & { minimizer: T extends any[] ? { [P in keyof T]: Minimizer } : Minimizer }} InternalPluginOptions */ /** * @template T * @typedef {T extends HtmlMinifierTerserOptions * ? { minify?: MinimizerImplementation | undefined, minimizerOptions?: MinimizerOptions | undefined } * : T extends any[] * ? { minify: { [P in keyof T]: MinimizerImplementation; }, minimizerOptions?: { [P in keyof T]?: MinimizerOptions | undefined; } | undefined } * : { minify: MinimizerImplementation, minimizerOptions?: MinimizerOptions | undefined }} DefinedDefaultMinimizerAndOptions */ /** * @template [T=HtmlMinifierTerserOptions] */ declare class HtmlMinimizerPlugin { /** * @private * @param {any} warning * @param {string} file * @returns {Error} */ private static buildWarning; /** * @private * @param {any} error * @param {string} file * @returns {Error} */ private static buildError; /** * @private * @param {Parallel} parallel * @returns {number} */ private static getAvailableNumberOfCores; /** * @param {BasePluginOptions & DefinedDefaultMinimizerAndOptions} [options] */ constructor( options?: | (BasePluginOptions & DefinedDefaultMinimizerAndOptions) | undefined ); /** * @private * @type {InternalPluginOptions} */ private options; /** * @private * @param {Compiler} compiler * @param {Compilation} compilation * @param {Record} assets * @param {{availableNumberOfCores: number}} optimizeOptions * @returns {Promise} */ private optimize; /** * @param {Compiler} compiler * @returns {void} */ apply(compiler: Compiler): void; } declare namespace HtmlMinimizerPlugin { export { htmlMinifierTerser, Schema, Compiler, Compilation, WebpackError, Asset, JestWorker, HtmlMinifierTerserOptions, Rule, Rules, MinimizedResult, Input, CustomOptions, InferDefaultType, MinimizerOptions, MinimizerImplementation, Minimizer, InternalOptions, InternalResult, MinimizerWorker, Parallel, BasePluginOptions, InternalPluginOptions, DefinedDefaultMinimizerAndOptions, }; } type Compiler = import("webpack").Compiler; type BasePluginOptions = { test?: Rules | undefined; include?: Rules | undefined; exclude?: Rules | undefined; parallel?: Parallel; }; type DefinedDefaultMinimizerAndOptions = T extends import("html-minifier-terser").Options ? { minify?: MinimizerImplementation | undefined; minimizerOptions?: MinimizerOptions | undefined; } : T extends any[] ? { minify: { [P in keyof T]: MinimizerImplementation }; minimizerOptions?: | { [P_1 in keyof T]?: MinimizerOptions } | undefined; } : { minify: MinimizerImplementation; minimizerOptions?: MinimizerOptions | undefined; }; import { htmlMinifierTerser } from "./utils"; type Schema = import("schema-utils/declarations/validate").Schema; type Compilation = import("webpack").Compilation; type WebpackError = import("webpack").WebpackError; type Asset = import("webpack").Asset; type JestWorker = import("jest-worker").Worker; type HtmlMinifierTerserOptions = import("./utils.js").HtmlMinifierTerserOptions; type Rule = RegExp | string; type Rules = Rule[] | Rule; type MinimizedResult = { code: string; errors?: unknown[] | undefined; warnings?: unknown[] | undefined; }; type Input = { [file: string]: string; }; type CustomOptions = { [key: string]: any; }; type InferDefaultType = T extends infer U ? U : CustomOptions; type MinimizerOptions = InferDefaultType | undefined; type MinimizerImplementation = ( input: Input, minimizerOptions?: MinimizerOptions ) => Promise; type Minimizer = { implementation: MinimizerImplementation; options?: MinimizerOptions | undefined; }; type InternalOptions = { name: string; input: string; minimizer: T extends any[] ? { [P in keyof T]: Minimizer } : Minimizer; }; type InternalResult = { code: string; warnings: Array; errors: Array; }; type MinimizerWorker = Worker & { transform: (options: string) => InternalResult; minify: (options: InternalOptions) => InternalResult; }; type Parallel = undefined | boolean | number; type InternalPluginOptions = BasePluginOptions & { minimizer: T extends any[] ? { [P in keyof T]: Minimizer } : Minimizer; }; import { minify } from "./minify"; import { Worker } from "jest-worker";