diff --git a/types/webpack/index.d.ts b/types/webpack/index.d.ts index 403036d378..0339a4ebb5 100644 --- a/types/webpack/index.d.ts +++ b/types/webpack/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for webpack 4.1 +// Type definitions for webpack 4.4 // Project: https://github.com/webpack/webpack // Definitions by: Qubo // Benjamin Lim @@ -560,7 +560,7 @@ declare namespace webpack { /** Assign modules to a cache group */ test?: ((...args: any[]) => boolean) | string | RegExp; /** Select chunks for determining cache group content (defaults to \"initial\", \"initial\" and \"all\" requires adding these chunks to the HTML) */ - chunks?: "initial" | "async" | "all"; + chunks?: "initial" | "async" | "all" | ((chunk: compilation.Chunk) => boolean); /** Ignore minimum size, minimum chunks and maximum requests and always create chunks for this cache group */ enforce?: boolean; /** Priority of this cache group */ @@ -580,7 +580,7 @@ declare namespace webpack { } interface SplitChunksOptions { /** Select chunks for determining shared modules (defaults to \"async\", \"initial\" and \"all\" requires adding these chunks to the HTML) */ - chunks?: "initial" | "async" | "all"; + chunks?: "initial" | "async" | "all" | ((chunk: compilation.Chunk) => boolean); /** Minimal size for the created chunk */ minSize?: number; /** Minimum number of times a module has to be duplicated until it's considered for splitting */ diff --git a/types/webpack/webpack-tests.ts b/types/webpack/webpack-tests.ts index ec5d0236a8..b7b9ca8913 100644 --- a/types/webpack/webpack-tests.ts +++ b/types/webpack/webpack-tests.ts @@ -607,6 +607,27 @@ configuration = { }, }; +configuration = { + mode: "production", + optimization: { + splitChunks: { + cacheGroups: { + common: { + name: 'common', + chunks(chunk: webpack.compilation.Chunk) { + const allowedChunks = [ + 'renderer', + 'component-window', + ]; + return allowedChunks.indexOf(chunk.name) >= 0; + }, + minChunks: 2 + } + } + } + }, +}; + plugin = new webpack.SplitChunksPlugin({ chunks: "async", minChunks: 2 }); class SingleEntryDependency extends webpack.compilation.Dependency {}