// Type definitions for compression-webpack-plugin 2.0 // Project: https://github.com/webpack-contrib/compression-webpack-plugin // Definitions by: Anton Kandybo // Rhys van der Waerden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.4 import { Plugin } from 'webpack'; import { ZlibOptions as ZlibCompressionOptions } from 'zlib'; export = CompressionPlugin; declare class CompressionPlugin extends Plugin { constructor(options?: CompressionPlugin.Options); } declare namespace CompressionPlugin { type AlgorithmCallback = (error: Error | null, result: Buffer) => void; type Algorithm = (source: string, options: O, callback: AlgorithmCallback) => void; // NOTE: These are the async compression algorithms on the zlib object. type ZlibAlgorithm = 'deflate' | 'deflateRaw' | 'gzip' | 'brotliCompress'; type Pattern = string | RegExp | ReadonlyArray | ReadonlyArray; interface BaseOptions { cache?: boolean | string; deleteOriginalAssets?: boolean; exclude?: Pattern; filename?: string; include?: Pattern; minRatio?: number; test?: Pattern; threshold?: number; } interface ZlibOptions extends BaseOptions { algorithm?: ZlibAlgorithm; compressionOptions?: ZlibCompressionOptions; } interface CustomOptions extends BaseOptions { algorithm: Algorithm; compressionOptions?: O; } type Options = ZlibOptions | CustomOptions; }