export = HtmlMinimizerPlugin;
/**
* @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,
swcMinify,
swcMinifyFragment,
minifyHtmlNode,
Schema,
Compiler,
Compilation,
WebpackError,
Asset,
JestWorker,
HtmlMinifierTerserOptions,
Rule,
Rules,
MinimizedResult,
Input,
CustomOptions,
InferDefaultType,
MinimizerOptions,
MinimizerImplementation,
Minimizer,
InternalOptions,
InternalResult,
MinimizerWorker,
Parallel,
BasePluginOptions,
InternalPluginOptions,
DefinedDefaultMinimizerAndOptions,
};
}
import { htmlMinifierTerser } from "./utils";
import { swcMinify } from "./utils";
import { swcMinifyFragment } from "./utils";
import { minifyHtmlNode } from "./utils";
type Schema = import("schema-utils/declarations/validate").Schema;
type Compiler = import("webpack").Compiler;
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 = import("jest-worker").Worker & {
transform: (options: string) => InternalResult;
minify: (options: InternalOptions) => InternalResult;
};
type Parallel = undefined | boolean | number;
type BasePluginOptions = {
test?: Rule | undefined;
include?: Rule | undefined;
exclude?: Rule | undefined;
parallel?: Parallel;
};
type InternalPluginOptions = BasePluginOptions & {
minimizer: T extends any[]
? { [P in keyof T]: Minimizer }
: Minimizer;
};
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;
};