UNPKG

2.07 kBTypeScriptView Raw
1/// <reference types="node" />
2/// <reference types="node" />
3import { ZlibOptions } from 'zlib';
4import { Plugin } from 'rollup';
5export type StringMappingOption = (originalString: string) => string;
6export type CustomCompressionOption = (content: string | Buffer) => string | Buffer | Promise<string | Buffer>;
7export interface GzipPluginOptions {
8 /**
9 * Control which of the output files to compress
10 *
11 * Defaults to `/\.(js|mjs|json|css|html)$/`
12 */
13 filter?: RegExp | ((fileName: string) => boolean);
14 /**
15 * GZIP compression options, see https://nodejs.org/api/zlib.html#zlib_class_options
16 */
17 gzipOptions?: ZlibOptions;
18 /**
19 * Specified the minimum size in Bytes for a file to get compressed.
20 * Files that are smaller than this threshold will not be compressed.
21 * This does not apply to the files specified through `additionalFiles`!
22 */
23 minSize?: number;
24 /**
25 * This option allows you to compress additional files outside of the main rollup bundling process.
26 * The processing is delayed to make sure the files are written on disk; the delay is controlled
27 * through `additionalFilesDelay`.
28 */
29 additionalFiles?: string[];
30 /**
31 * This options sets a delay (ms) before the plugin compresses the files specified through `additionalFiles`.
32 * Increase this value if your artifacts take a long time to generate.
33 *
34 * Defaults to `0`
35 */
36 additionalFilesDelay?: number;
37 /**
38 * Set a custom compression algorithm. The function can either return the compressed contents synchronously,
39 * or otherwise return a promise for asynchronous processing.
40 */
41 customCompression?: CustomCompressionOption;
42 /**
43 * Set a custom file name convention for the compressed files. Can be a suffix string or a function
44 * returning the file name.
45 *
46 * Defaults to `.gz`
47 */
48 fileName?: string | StringMappingOption;
49}
50declare function gzipPlugin(explicitOptions?: GzipPluginOptions): Plugin;
51export default gzipPlugin;
52
\No newline at end of file