DefinitelyTyped/types/terser-webpack-plugin/index.d.ts
즈눅 b4f18cc47a [terser-webpack-plugin] bump up version (#39907)
* [terser-webpack-plugin] bump up version

* source argument can be undefined
2019-11-04 16:31:58 -08:00

55 lines
1.8 KiB
TypeScript

// Type definitions for terser-webpack-plugin 2.2
// Project: https://github.com/webpack-contrib/terser-webpack-plugin
// Definitions by: Daniel Schopf <https://github.com/Danscho>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
import { Plugin } from 'webpack';
import { MinifyOptions } from 'terser';
import webpack = require('webpack');
export = TerserPlugin;
declare class TerserPlugin extends Plugin {
constructor(opts?: TerserPlugin.TerserPluginOptions);
}
declare namespace TerserPlugin {
interface MinifyResult {
error: any;
map: any;
code: any;
warnings: any;
extractedComments: any;
}
interface ExtractCommentOptions {
condition: boolean | string | RegExp | ExtractCommentFn | object;
filename?: string | FormatFn;
banner?: boolean | string | FormatFn;
}
type ExtractCommentFn = (node: any, comment: any) => (boolean | object);
type FormatFn = (input: string) => string;
interface TerserPluginOptions {
test?: string | RegExp | Array<string | RegExp>;
include?: string | RegExp | Array<string | RegExp>;
exclude?: string | RegExp | Array<string | RegExp>;
chunkFilter?: (chunk: webpack.compilation.Chunk) => boolean;
cache?: boolean | string;
cacheKeys?: (defaultCacheKeys: any, file: any) => object;
parallel?: boolean | number;
sourceMap?: boolean;
minify?: (file: any, sourceMap: any) => MinifyResult;
terserOptions?: MinifyOptions;
extractComments?: boolean
| string
| RegExp
| ExtractCommentFn
| ExtractCommentOptions;
warningsFilter?: (warning: string, source: string | undefined, file: string) => boolean;
}
}