mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Merge pull request #25781 from mnquintana/webpack-4-split-chunks-chunks-func
[@types/webpack] Add support for chunks filter function in SplitChunksPlugin
This commit is contained in:
6
types/webpack/index.d.ts
vendored
6
types/webpack/index.d.ts
vendored
@@ -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 <https://github.com/tkqubo>
|
||||
// Benjamin Lim <https://github.com/bumbleblym>
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 {}
|
||||
|
||||
Reference in New Issue
Block a user