From 632b1094505cace413384a3b0ec1fef10af129da Mon Sep 17 00:00:00 2001 From: neverland Date: Thu, 11 Apr 2024 15:02:08 +0800 Subject: [PATCH] docs: add async chunk all in one example (#2067) --- .../en/config/performance/chunk-split.mdx | 34 ++++---- .../docs/en/guide/optimization/split-chunk.md | 77 ++++++++++++++----- .../zh/config/performance/chunk-split.mdx | 34 ++++---- .../docs/zh/guide/optimization/split-chunk.md | 77 ++++++++++++++----- 4 files changed, 148 insertions(+), 74 deletions(-) diff --git a/packages/document/docs/en/config/performance/chunk-split.mdx b/packages/document/docs/en/config/performance/chunk-split.mdx index ae780480bb..05bacadb25 100644 --- a/packages/document/docs/en/config/performance/chunk-split.mdx +++ b/packages/document/docs/en/config/performance/chunk-split.mdx @@ -35,7 +35,7 @@ interface SplitCustom { type ChunkSplit = BaseChunkSplit | SplitBySize | SplitCustom; ``` -### chunkSplit.strategy +## chunkSplit.strategy Rsbuild supports the following chunk splitting strategies: @@ -48,21 +48,23 @@ Rsbuild supports the following chunk splitting strategies: ### Default Strategy -Rsbuild adopts the `split-by-experience` strategy by default, which is a strategy we have developed from experience. Specifically, when the following npm packages are referenced in your project, they will automatically be split into separate chunks: +By default, Rsbuild uses the `split-by-experience` strategy. If you want to use other chunk splitting strategies, you can specify them through the `strategy` option, for example: -- `lib-polyfill.js`: includes `core-js`, `@babel/runtime`, `@swc/helpers`, `tslib`. -- `lib-react.js`: includes `react`, `react-dom`, `scheduler`. -- `lib-router.js`: includes `react-router`, `react-router-dom`, `history`, `@remix-run/router`. -- `lib-lodash.js`: includes `lodash`, `lodash-es`. -- `lib-axios.js`: includes `axios` and related packages. +```js +export default { + performance: { + chunkSplit: { + strategy: 'all-in-one', + }, + }, +}; +``` -:::tip -If the above npm packages are not installed or used in the project, the corresponding chunk will not be generated. +::: tip +Please refer to the [Chunk Splitting Practice](/guide/optimization/split-chunk) section to understand the differences between different strategies. ::: -If you want to use other splitting strategies, you can specify it via `performance.chunkSplit.strategy`. - -### chunkSplit.minSize +## chunkSplit.minSize - **Type:** `number` - **Default:** `10000` @@ -80,7 +82,7 @@ export default { }; ``` -### chunkSplit.maxSize +## chunkSplit.maxSize - **Type:** `number` - **Default:** `Number.POSITIVE_INFINITY` @@ -98,7 +100,7 @@ export default { }; ``` -### chunkSplit.forceSplitting +## chunkSplit.forceSplitting - **Type:** `RegExp[] | Record` - **Default:** `[]` @@ -125,7 +127,7 @@ This is an easier way than configuring Rspack's splitChunks directly. Chunks split using the `forceSplitting` configuration will be inserted into the HTML file as resources requested for the initial screen using `