diff --git a/types/webpack-bundle-analyzer/index.d.ts b/types/webpack-bundle-analyzer/index.d.ts index 6b2db94b65..f1e3f2a3c6 100644 --- a/types/webpack-bundle-analyzer/index.d.ts +++ b/types/webpack-bundle-analyzer/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack-bundle-analyzer 2.9 +// Type definitions for webpack-bundle-analyzer 2.13 // Project: https://github.com/th0r/webpack-bundle-analyzer // Definitions by: Michael Strobel // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,6 +7,9 @@ import * as webpack from 'webpack'; export namespace BundleAnalyzerPlugin { + type ExcludeAssetsPatternFn = (assetName: string) => boolean; + type ExcludeAssetsPattern = string | RegExp | ExcludeAssetsPatternFn; + interface Options { /** * Can be "server", "static" or "disabled". @@ -68,6 +71,16 @@ export namespace BundleAnalyzerPlugin { */ statsOptions?: null | webpack.Stats.ToJsonOptionsObject; + /** + * Default: `null`. + * Patterns that will be used to match against asset names to exclude them from the report. + * If pattern is a string it will be converted to RegExp via `new RegExp(str)`. + * If pattern is a function it should have the following signature `(assetName: string) => boolean` + * and should return true to exclude matching asset. + * If multiple patterns are provided asset should match at least one of them to be excluded. + */ + excludeAssets?: null | ExcludeAssetsPattern | ExcludeAssetsPattern[]; + /** * Log level. Can be "info", "warn", "error" or "silent". * Defaults to "info" diff --git a/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts b/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts index 0b5fcabcc7..7aa2b0aee7 100644 --- a/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts +++ b/types/webpack-bundle-analyzer/webpack-bundle-analyzer-tests.ts @@ -19,6 +19,11 @@ const config: webpack.Configuration = { statsOptions: { source: false }, + excludeAssets: [ + 'foo', + /foo/, + assetName => assetName.indexOf('foo') !== -1 + ], logLevel: 'info' }) ]