webpack: add missing uglifyjs plugin typings (#14177)

This commit is contained in:
Matt Lewis
2017-01-23 02:19:26 +00:00
committed by Mohamed Hegazy
parent 756433aeb4
commit 02c09ed9d8
2 changed files with 25 additions and 1 deletions

13
webpack/index.d.ts vendored
View File

@@ -472,6 +472,17 @@ declare namespace webpack {
apply(thisArg: Webpack, ...args: any[]): void;
}
type UglifyCommentFunction = (astNode: any, comment: any) => boolean
interface UglifyPluginOptions extends UglifyJS.MinifyOptions {
beautify?: boolean;
comments?: boolean | RegExp | UglifyCommentFunction;
sourceMap?: boolean;
test?: Condition | Condition[];
include?: Condition | Condition[];
exclude?: Condition | Condition[];
}
interface Webpack {
(config: Configuration, callback?: compiler.CompilerCallback): compiler.Compiler;
/**
@@ -1020,7 +1031,7 @@ declare namespace webpack {
new (preferEntry: boolean): Plugin;
}
interface UglifyJsPluginStatic {
new (options?: UglifyJS.MinifyOptions): Plugin;
new (options?: UglifyPluginOptions): Plugin;
}
interface CommonsChunkPluginStatic {
new (chunkName: string, filenames?: string | string[]): Plugin;

View File

@@ -288,11 +288,24 @@ plugin = new webpack.optimize.UglifyJsPlugin({
warnings: false
}
});
plugin = new webpack.optimize.UglifyJsPlugin({
sourceMap: false,
comments: true,
beautify: true,
test: 'foo',
exclude: /node_modules/,
include: 'test'
});
plugin = new webpack.optimize.UglifyJsPlugin({
mangle: {
except: ['$super', '$', 'exports', 'require']
}
});
plugin = new webpack.optimize.UglifyJsPlugin({
comments: function(astNode: any, comment: any) {
return false;
}
});
plugin = new webpack.optimize.CommonsChunkPlugin(options);
plugin = new CommonsChunkPlugin({
name: "commons",