@modern-js/main-doc 0.0.0-nightly-20250515160310 → 0.0.0-nightly-20250518160324
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/docs/en/apis/app/hooks/src/routes.mdx +3 -3
- package/docs/en/components/rsbuild-config-tooltip.mdx +2 -2
- package/docs/en/configure/app/dev/asset-prefix.mdx +2 -3
- package/docs/en/configure/app/dev/client.mdx +2 -3
- package/docs/en/configure/app/dev/hmr.mdx +2 -3
- package/docs/en/configure/app/dev/live-reload.mdx +2 -3
- package/docs/en/configure/app/dev/progress-bar.mdx +2 -3
- package/docs/en/configure/app/dev/setup-middlewares.mdx +2 -3
- package/docs/en/configure/app/dev/watch-files.mdx +2 -3
- package/docs/en/configure/app/dev/write-to-disk.mdx +2 -3
- package/docs/en/configure/app/html/app-icon.mdx +2 -3
- package/docs/en/configure/app/html/crossorigin.mdx +2 -3
- package/docs/en/configure/app/html/favicon.mdx +2 -3
- package/docs/en/configure/app/html/inject.mdx +2 -3
- package/docs/en/configure/app/html/meta.mdx +2 -3
- package/docs/en/configure/app/html/mount-id.mdx +2 -3
- package/docs/en/configure/app/html/output-structure.mdx +2 -3
- package/docs/en/configure/app/html/script-loading.mdx +2 -3
- package/docs/en/configure/app/html/tags.mdx +2 -3
- package/docs/en/configure/app/html/template-parameters.mdx +2 -3
- package/docs/en/configure/app/html/template.mdx +2 -3
- package/docs/en/configure/app/html/title.mdx +2 -3
- package/docs/en/configure/app/output/asset-prefix.mdx +2 -3
- package/docs/en/configure/app/output/charset.mdx +2 -3
- package/docs/en/configure/app/output/copy.mdx +2 -3
- package/docs/en/configure/app/output/css-modules.mdx +2 -3
- package/docs/en/configure/app/output/data-uri-limit.mdx +2 -3
- package/docs/en/configure/app/output/dist-path.mdx +2 -3
- package/docs/en/configure/app/output/externals.mdx +2 -3
- package/docs/en/configure/app/output/filename-hash.mdx +2 -3
- package/docs/en/configure/app/output/filename.mdx +2 -3
- package/docs/en/configure/app/output/inject-styles.mdx +2 -3
- package/docs/en/configure/app/output/inline-scripts.mdx +2 -3
- package/docs/en/configure/app/output/inline-styles.mdx +2 -3
- package/docs/en/configure/app/output/legal-comments.mdx +2 -3
- package/docs/en/configure/app/output/minify.mdx +2 -3
- package/docs/en/configure/app/output/override-browserslist.mdx +2 -3
- package/docs/en/configure/app/output/polyfill.mdx +2 -3
- package/docs/en/configure/app/output/source-map.mdx +2 -3
- package/docs/en/configure/app/performance/build-cache.mdx +2 -3
- package/docs/en/configure/app/performance/bundle-analyze.mdx +2 -3
- package/docs/en/configure/app/performance/chunk-split.mdx +2 -3
- package/docs/en/configure/app/performance/dns-prefetch.mdx +2 -3
- package/docs/en/configure/app/performance/preconnect.mdx +2 -3
- package/docs/en/configure/app/performance/prefetch.mdx +2 -3
- package/docs/en/configure/app/performance/preload.mdx +2 -3
- package/docs/en/configure/app/performance/print-file-size.mdx +2 -3
- package/docs/en/configure/app/performance/profile.mdx +2 -3
- package/docs/en/configure/app/performance/remove-console.mdx +2 -3
- package/docs/en/configure/app/performance/remove-moment-locale.mdx +2 -3
- package/docs/en/configure/app/security/nonce.mdx +2 -3
- package/docs/en/configure/app/security/sri.mdx +0 -1
- package/docs/en/configure/app/server/port.mdx +2 -3
- package/docs/en/configure/app/source/alias-strategy.mdx +2 -3
- package/docs/en/configure/app/source/alias.mdx +2 -3
- package/docs/en/configure/app/source/decorators.mdx +2 -3
- package/docs/en/configure/app/source/define.mdx +2 -3
- package/docs/en/configure/app/source/exclude.mdx +2 -3
- package/docs/en/configure/app/source/include.mdx +2 -3
- package/docs/en/configure/app/source/pre-entry.mdx +2 -3
- package/docs/en/configure/app/source/transform-import.mdx +2 -3
- package/docs/en/configure/app/tools/css-extract.mdx +2 -3
- package/docs/en/configure/app/tools/css-loader.mdx +2 -2
- package/docs/en/configure/app/tools/html-plugin.mdx +2 -3
- package/docs/en/configure/app/tools/lightningcss-loader.mdx +2 -3
- package/docs/en/configure/app/tools/postcss.mdx +2 -3
- package/docs/en/configure/app/tools/rspack.mdx +2 -3
- package/docs/en/configure/app/tools/style-loader.mdx +2 -3
- package/docs/en/tutorials/first-app/c04-routes.mdx +4 -2
- package/docs/en/tutorials/first-app/c05-loader.mdx +4 -1
- package/docs/zh/apis/app/hooks/src/routes.mdx +3 -3
- package/docs/zh/components/rsbuild-config-tooltip.mdx +2 -2
- package/docs/zh/configure/app/dev/asset-prefix.mdx +2 -3
- package/docs/zh/configure/app/dev/client.mdx +2 -3
- package/docs/zh/configure/app/dev/hmr.mdx +2 -3
- package/docs/zh/configure/app/dev/live-reload.mdx +2 -3
- package/docs/zh/configure/app/dev/progress-bar.mdx +2 -3
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +2 -3
- package/docs/zh/configure/app/dev/watch-files.mdx +2 -3
- package/docs/zh/configure/app/dev/write-to-disk.mdx +2 -3
- package/docs/zh/configure/app/html/app-icon.mdx +2 -3
- package/docs/zh/configure/app/html/crossorigin.mdx +2 -3
- package/docs/zh/configure/app/html/favicon.mdx +2 -3
- package/docs/zh/configure/app/html/inject.mdx +2 -3
- package/docs/zh/configure/app/html/meta.mdx +2 -3
- package/docs/zh/configure/app/html/mount-id.mdx +2 -3
- package/docs/zh/configure/app/html/output-structure.mdx +2 -3
- package/docs/zh/configure/app/html/script-loading.mdx +2 -3
- package/docs/zh/configure/app/html/tags.mdx +2 -3
- package/docs/zh/configure/app/html/template-parameters.mdx +2 -3
- package/docs/zh/configure/app/html/template.mdx +2 -3
- package/docs/zh/configure/app/html/title.mdx +2 -3
- package/docs/zh/configure/app/output/asset-prefix.mdx +2 -3
- package/docs/zh/configure/app/output/charset.mdx +2 -3
- package/docs/zh/configure/app/output/copy.mdx +2 -3
- package/docs/zh/configure/app/output/css-modules.mdx +2 -3
- package/docs/zh/configure/app/output/data-uri-limit.mdx +2 -3
- package/docs/zh/configure/app/output/dist-path.mdx +2 -3
- package/docs/zh/configure/app/output/externals.mdx +2 -3
- package/docs/zh/configure/app/output/filename-hash.mdx +2 -3
- package/docs/zh/configure/app/output/filename.mdx +2 -3
- package/docs/zh/configure/app/output/inject-styles.mdx +2 -3
- package/docs/zh/configure/app/output/inline-scripts.mdx +2 -3
- package/docs/zh/configure/app/output/inline-styles.mdx +2 -3
- package/docs/zh/configure/app/output/legal-comments.mdx +2 -3
- package/docs/zh/configure/app/output/minify.mdx +2 -3
- package/docs/zh/configure/app/output/override-browserslist.mdx +2 -3
- package/docs/zh/configure/app/output/polyfill.mdx +2 -3
- package/docs/zh/configure/app/output/source-map.mdx +2 -3
- package/docs/zh/configure/app/performance/build-cache.mdx +2 -3
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +2 -3
- package/docs/zh/configure/app/performance/chunk-split.mdx +2 -3
- package/docs/zh/configure/app/performance/dns-prefetch.mdx +2 -3
- package/docs/zh/configure/app/performance/preconnect.mdx +2 -3
- package/docs/zh/configure/app/performance/prefetch.mdx +2 -3
- package/docs/zh/configure/app/performance/preload.mdx +2 -3
- package/docs/zh/configure/app/performance/print-file-size.mdx +2 -3
- package/docs/zh/configure/app/performance/profile.mdx +2 -3
- package/docs/zh/configure/app/performance/remove-console.mdx +2 -3
- package/docs/zh/configure/app/performance/remove-moment-locale.mdx +2 -3
- package/docs/zh/configure/app/security/nonce.mdx +2 -3
- package/docs/zh/configure/app/security/sri.mdx +0 -1
- package/docs/zh/configure/app/server/port.mdx +2 -3
- package/docs/zh/configure/app/source/alias-strategy.mdx +2 -3
- package/docs/zh/configure/app/source/alias.mdx +2 -3
- package/docs/zh/configure/app/source/decorators.mdx +2 -3
- package/docs/zh/configure/app/source/define.mdx +2 -3
- package/docs/zh/configure/app/source/exclude.mdx +2 -3
- package/docs/zh/configure/app/source/include.mdx +2 -3
- package/docs/zh/configure/app/source/pre-entry.mdx +2 -3
- package/docs/zh/configure/app/source/transform-import.mdx +2 -3
- package/docs/zh/configure/app/tools/css-extract.mdx +2 -3
- package/docs/zh/configure/app/tools/css-loader.mdx +2 -3
- package/docs/zh/configure/app/tools/html-plugin.mdx +2 -3
- package/docs/zh/configure/app/tools/lightningcss-loader.mdx +2 -3
- package/docs/zh/configure/app/tools/postcss.mdx +2 -3
- package/docs/zh/configure/app/tools/rspack.mdx +2 -3
- package/docs/zh/configure/app/tools/style-loader.mdx +2 -3
- package/docs/zh/tutorials/first-app/c04-routes.mdx +4 -2
- package/docs/zh/tutorials/first-app/c05-loader.mdx +4 -1
- package/package.json +6 -4
- package/rspress.config.ts +6 -1
- package/src/components/RsbuildLink/index.tsx +2 -2
- package/src/index.ts +1 -5
- package/src/pages/index.tsx +3 -3
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: buildCache
|
|
3
|
-
configName: performance.buildCache
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.buildCache
|
|
@@ -41,6 +40,6 @@ export default {
|
|
|
41
40
|
|
|
42
41
|
It should be noted that, Rspack's persistent cache is [experimental](https://rspack.dev/config/experiments#experimentscache), which may change in future versions, and this feature needs to be turned on manually.
|
|
43
42
|
|
|
44
|
-
import
|
|
43
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
45
44
|
|
|
46
|
-
<
|
|
45
|
+
<RsbuildConfig configName="performance.buildCache" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: bundleAnalyze
|
|
3
|
-
configName: performance.bundleAnalyze
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.bundleAnalyze
|
|
@@ -20,6 +19,6 @@ const defaultConfig = {
|
|
|
20
19
|
};
|
|
21
20
|
```
|
|
22
21
|
|
|
23
|
-
import
|
|
22
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
24
23
|
|
|
25
|
-
<
|
|
24
|
+
<RsbuildConfig configName="performance.bundleAnalyze" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: chunkSplit
|
|
3
|
-
configName: performance.chunkSplit
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.chunkSplit
|
|
@@ -40,6 +39,6 @@ interface SplitCustom {
|
|
|
40
39
|
export type ChunkSplit = BaseChunkSplit | SplitBySize | SplitCustom;
|
|
41
40
|
```
|
|
42
41
|
|
|
43
|
-
import
|
|
42
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
44
43
|
|
|
45
|
-
<
|
|
44
|
+
<RsbuildConfig configName="performance.chunkSplit" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: dnsPrefetch
|
|
3
|
-
configName: performance.dnsPrefetch
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.dnsPrefetch
|
|
@@ -15,6 +14,6 @@ After this property is set, the domain name can be resolved before the resource
|
|
|
15
14
|
|
|
16
15
|
See [Using dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch) for more details.
|
|
17
16
|
|
|
18
|
-
import
|
|
17
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
19
18
|
|
|
20
|
-
<
|
|
19
|
+
<RsbuildConfig configName="performance.dnsPrefetch" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: preconnect
|
|
3
|
-
configName: performance.preconnect
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.preconnect
|
|
@@ -16,6 +15,6 @@ interface PreconnectOption {
|
|
|
16
15
|
|
|
17
16
|
- **Default:** `undefined`
|
|
18
17
|
|
|
19
|
-
import
|
|
18
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
20
19
|
|
|
21
|
-
<
|
|
20
|
+
<RsbuildConfig configName="performance.preconnect" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: prefetch
|
|
3
|
-
configName: performance.prefetch
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.prefetch
|
|
@@ -21,6 +20,6 @@ interface PrefetchOption {
|
|
|
21
20
|
|
|
22
21
|
- **Default:** `undefined`
|
|
23
22
|
|
|
24
|
-
import
|
|
23
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
25
24
|
|
|
26
|
-
<
|
|
25
|
+
<RsbuildConfig configName="performance.prefetch" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: preload
|
|
3
|
-
configName: performance.preload
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.preload
|
|
@@ -23,6 +22,6 @@ interface PreloadOption {
|
|
|
23
22
|
|
|
24
23
|
Inject the [`<link rel="preload">`](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Attributes/rel/preload) tags for the static assets generated by Rsbuild.
|
|
25
24
|
|
|
26
|
-
import
|
|
25
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
27
26
|
|
|
28
|
-
<
|
|
27
|
+
<RsbuildConfig configName="performance.preload" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: printFileSize
|
|
3
|
-
configName: performance.printFileSize
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.printFileSize
|
|
@@ -40,6 +39,6 @@ info Production file sizes:
|
|
|
40
39
|
dist/static/css/main.03221f72.css 1.4 kB 741 B
|
|
41
40
|
```
|
|
42
41
|
|
|
43
|
-
import
|
|
42
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
44
43
|
|
|
45
|
-
<
|
|
44
|
+
<RsbuildConfig configName="performance.printFileSize" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: profile
|
|
3
|
-
configName: performance.profile
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.profile
|
|
@@ -10,6 +9,6 @@ configName: performance.profile
|
|
|
10
9
|
|
|
11
10
|
Whether capture timing information for each module, same as the [profile](https://webpack.js.org/configuration/other-options/#profile) config of Rspack.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="performance.profile" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: removeConsole
|
|
3
|
-
configName: performance.removeConsole
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.removeConsole
|
|
@@ -10,6 +9,6 @@ configName: performance.removeConsole
|
|
|
10
9
|
|
|
11
10
|
Whether to remove `console.[methodName]` in production build.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="performance.removeConsole" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: removeMomentLocale
|
|
3
|
-
configName: performance.removeMomentLocale
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# performance.removeMomentLocale
|
|
@@ -10,6 +9,6 @@ configName: performance.removeMomentLocale
|
|
|
10
9
|
|
|
11
10
|
Whether to remove the locales of [moment.js](https://momentjs.com/).
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="performance.removeMomentLocale" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: nonce
|
|
3
|
-
configName: security.nonce
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# security.nonce
|
|
@@ -15,6 +14,6 @@ type Nonce = string;
|
|
|
15
14
|
|
|
16
15
|
Adding a `nonce` attribute to the scripts resources introduced for HTML. This allows the browser to determine whether the script can be executed when it parses inline scripts with matching nonce values.
|
|
17
16
|
|
|
18
|
-
import
|
|
17
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
19
18
|
|
|
20
|
-
<
|
|
19
|
+
<RsbuildConfig configName="security.nonce" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: port
|
|
3
|
-
configName: server.port
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# server.port
|
|
@@ -38,6 +37,6 @@ export default defineConfig({
|
|
|
38
37
|
});
|
|
39
38
|
```
|
|
40
39
|
|
|
41
|
-
import
|
|
40
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
42
41
|
|
|
43
|
-
<
|
|
42
|
+
<RsbuildConfig configName="server.port" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: aliasStrategy
|
|
3
|
-
configName: source.aliasStrategy
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.aliasStrategy
|
|
@@ -10,6 +9,6 @@ configName: source.aliasStrategy
|
|
|
10
9
|
|
|
11
10
|
`source.aliasStrategy` is used to control the priority between the `paths` option in `tsconfig.json` and the `alias` option in the bundler.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="source.aliasStrategy" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: alias
|
|
3
|
-
configName: source.alias
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.alias
|
|
@@ -19,6 +18,6 @@ Create aliases to import or require certain modules, same as the [resolve.alias]
|
|
|
19
18
|
For TypeScript projects, you only need to configure [compilerOptions.paths](https://www.typescriptlang.org/tsconfig#paths) in the `tsconfig.json` file. The Rsbuild will automatically recognize it, so there is no need to configure the `source.alias` option separately. For more details, please refer to [Path Aliases](https://modernjs.dev/en/guides/basic-features/alias.html).
|
|
20
19
|
:::
|
|
21
20
|
|
|
22
|
-
import
|
|
21
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
23
22
|
|
|
24
|
-
<
|
|
23
|
+
<RsbuildConfig configName="source.alias" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: decorators
|
|
3
|
-
configName: source.decorators
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.decorators
|
|
@@ -23,6 +22,6 @@ const defaultDecorators = {
|
|
|
23
22
|
|
|
24
23
|
Used to configure the decorators syntax.
|
|
25
24
|
|
|
26
|
-
import
|
|
25
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
27
26
|
|
|
28
|
-
<
|
|
27
|
+
<RsbuildConfig configName="source.decorators" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: define
|
|
3
|
-
configName: source.define
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.define
|
|
@@ -16,6 +15,6 @@ const defaultDefine = {
|
|
|
16
15
|
|
|
17
16
|
Replaces variables in your code with other values or expressions at compile time. This can be useful for allowing different behavior between development builds and production builds.
|
|
18
17
|
|
|
19
|
-
import
|
|
18
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
20
19
|
|
|
21
|
-
<
|
|
20
|
+
<RsbuildConfig configName="source.define" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: exclude
|
|
3
|
-
configName: source.exclude
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.exclude
|
|
@@ -10,6 +9,6 @@ configName: source.exclude
|
|
|
10
9
|
|
|
11
10
|
Specifies JavaScript/TypeScript files that do not need to be compiled. The usage is consistent with [Rule.exclude](https://rspack.dev/config/module#ruleexclude) in Rspack, which supports passing in strings or regular expressions to match the module path.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="source.exclude" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: include
|
|
3
|
-
configName: source.include
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.include
|
|
@@ -21,6 +20,6 @@ const defaultInclude = [
|
|
|
21
20
|
|
|
22
21
|
The `source.include` is used to specify additional JavaScript files that need to be compiled.
|
|
23
22
|
|
|
24
|
-
import
|
|
23
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
25
24
|
|
|
26
|
-
<
|
|
25
|
+
<RsbuildConfig configName="source.include" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: preEntry
|
|
3
|
-
configName: source.preEntry
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.preEntry
|
|
@@ -10,6 +9,6 @@ configName: source.preEntry
|
|
|
10
9
|
|
|
11
10
|
Add a script before the entry file of each page. This script will be executed before the page code. It can be used to execute global logics, such as injecting polyfills, setting global styles, etc.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="source.preEntry" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: transformImport
|
|
3
|
-
configName: source.transformImport
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# source.transformImport
|
|
@@ -59,9 +58,9 @@ const defaultArcoConfig = [
|
|
|
59
58
|
When you add configurations for `antd` or `@arco-design/web-react`, the priority will be higher than the default configurations mentioned above.
|
|
60
59
|
:::
|
|
61
60
|
|
|
62
|
-
import
|
|
61
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
63
62
|
|
|
64
|
-
<
|
|
63
|
+
<RsbuildConfig configName="source.transformImport" />
|
|
65
64
|
|
|
66
65
|
### Disable Default Config
|
|
67
66
|
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: cssExtract
|
|
3
|
-
configName: tools.cssExtract
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.cssExtract
|
|
@@ -33,6 +32,6 @@ const defaultOptions = {
|
|
|
33
32
|
|
|
34
33
|
The config of [CssExtractRspackPlugin](https://www.rspack.dev/plugins/rspack/css-extract-rspack-plugin) / [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) can be modified through `tools.cssExtract`.
|
|
35
34
|
|
|
36
|
-
import
|
|
35
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
37
36
|
|
|
38
|
-
<
|
|
37
|
+
<RsbuildConfig configName="tools.cssExtract" />
|
|
@@ -16,6 +16,6 @@ const defaultOptions = {
|
|
|
16
16
|
|
|
17
17
|
The config of [css-loader](https://github.com/webpack-contrib/css-loader) can be modified through `tools.cssLoader`.
|
|
18
18
|
|
|
19
|
-
import
|
|
19
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
20
20
|
|
|
21
|
-
<
|
|
21
|
+
<RsbuildConfig configName="tools.cssLoader" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: htmlPlugin
|
|
3
|
-
configName: tools.htmlPlugin
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.htmlPlugin
|
|
@@ -36,6 +35,6 @@ const defaultOptions = {
|
|
|
36
35
|
|
|
37
36
|
The configs of [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin) or [html-webpack-plugin](https://github.com/jantimon/html-webpack-plugin) can be modified through `tools.htmlPlugin`.
|
|
38
37
|
|
|
39
|
-
import
|
|
38
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
40
39
|
|
|
41
|
-
<
|
|
40
|
+
<RsbuildConfig configName="tools.htmlPlugin" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: lightningcssLoader
|
|
3
|
-
configName: tools.lightningcssLoader
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.lightningcssLoader
|
|
@@ -36,6 +35,6 @@ const defaultOptions = {
|
|
|
36
35
|
|
|
37
36
|
It should be noted that when `lightningcss-loader` is turned on, `postcss-loader` will be turned off by default.
|
|
38
37
|
|
|
39
|
-
import
|
|
38
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
40
39
|
|
|
41
|
-
<
|
|
40
|
+
<RsbuildConfig configName="tools.lightningcssLoader" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: postcss
|
|
3
|
-
configName: tools.postcss
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.postcss
|
|
@@ -34,6 +33,6 @@ Modern.js integrates PostCSS by default, you can configure [postcss-loader](http
|
|
|
34
33
|
|
|
35
34
|
It should be noted that when you enable the `tools.lightningcss` configuration, PostCSS will be disabled by default, including `postcss-loader` and its default plugins.
|
|
36
35
|
|
|
37
|
-
import
|
|
36
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
38
37
|
|
|
39
|
-
<
|
|
38
|
+
<RsbuildConfig configName="tools.postcss" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: rspack
|
|
3
|
-
configName: tools.rspack
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.rspack
|
|
@@ -10,6 +9,6 @@ configName: tools.rspack
|
|
|
10
9
|
|
|
11
10
|
`tools.rspack` is used to configure [Rspack](https://rspack.dev/).
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="tools.rspack" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: styleLoader
|
|
3
|
-
configName: tools.styleLoader
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# tools.styleLoader
|
|
@@ -10,6 +9,6 @@ configName: tools.styleLoader
|
|
|
10
9
|
|
|
11
10
|
The config of [style-loader](https://github.com/webpack-contrib/style-loader) can be set through `tools.styleLoader`.
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs-en/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="tools.styleLoader" />
|
|
@@ -118,10 +118,11 @@ import { Radio } from 'antd';
|
|
|
118
118
|
|
|
119
119
|
Then modify the top of the UI to add a set of radio group:
|
|
120
120
|
|
|
121
|
-
```tsx
|
|
121
|
+
```tsx
|
|
122
122
|
export default function Layout() {
|
|
123
123
|
return (
|
|
124
124
|
<div>
|
|
125
|
+
// [!code highlight:6]
|
|
125
126
|
<div className="h-16 p-2 flex items-center justify-center">
|
|
126
127
|
<Radio.Group onChange={handleSetList} value={currentList}>
|
|
127
128
|
<Radio value="/">All</Radio>
|
|
@@ -146,8 +147,9 @@ import { Outlet, useLocation, useNavigate } from '@modern-js/runtime/router';
|
|
|
146
147
|
|
|
147
148
|
Finally, add local state and related logic to the Layout component:
|
|
148
149
|
|
|
149
|
-
```tsx
|
|
150
|
+
```tsx
|
|
150
151
|
export default function Layout() {
|
|
152
|
+
// [!code highlight:8]
|
|
151
153
|
const navigate = useNavigate();
|
|
152
154
|
const location = useLocation();
|
|
153
155
|
const [currentList, setList] = useState(location.pathname || '/');
|
|
@@ -56,11 +56,13 @@ Data Loader doesn't just work for SSR. In CSR projects, Data Loader can also avo
|
|
|
56
56
|
|
|
57
57
|
Modern.js also provides a hooks API called `useLoaderData`, we modify the exported component of `src/routes/page.tsx`:
|
|
58
58
|
|
|
59
|
-
```tsx
|
|
59
|
+
```tsx
|
|
60
|
+
// [!code highlight:2]
|
|
60
61
|
import { useLoaderData } from '@modern-js/runtime/router';
|
|
61
62
|
import type { LoaderData } from './page.data';
|
|
62
63
|
|
|
63
64
|
function Index() {
|
|
65
|
+
// [!code highlight:1]
|
|
64
66
|
const { data } = useLoaderData() as LoaderData;
|
|
65
67
|
|
|
66
68
|
return (
|
|
@@ -68,6 +70,7 @@ function Index() {
|
|
|
68
70
|
<Helmet>
|
|
69
71
|
<title>All</title>
|
|
70
72
|
</Helmet>
|
|
73
|
+
// [!code highlight:1]
|
|
71
74
|
<List
|
|
72
75
|
dataSource={data}
|
|
73
76
|
renderItem={info => <Item key={info.name} info={info} />}
|
|
@@ -10,11 +10,11 @@ sidebar_position: 2
|
|
|
10
10
|
|
|
11
11
|
任何在 `src/routes` 下的 `layout.[tj]sx` 和 `page.[tj]sx` 都会作为应用的路由:
|
|
12
12
|
|
|
13
|
-
```bash
|
|
13
|
+
```bash
|
|
14
14
|
.
|
|
15
15
|
└── routes
|
|
16
|
-
├── layout.tsx
|
|
17
|
-
├── page.tsx
|
|
16
|
+
├── layout.tsx # [!code highlight]
|
|
17
|
+
├── page.tsx # [!code highlight]
|
|
18
18
|
└── user
|
|
19
19
|
├── layout.tsx
|
|
20
20
|
└── page.tsx
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import RsbuildLink from '@site/src/components/RsbuildLink';
|
|
2
2
|
|
|
3
3
|
:::info
|
|
4
|
-
该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 <
|
|
4
|
+
该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 <RsbuildLink configName={props.configName}/>。
|
|
5
5
|
:::
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: assetPrefix
|
|
3
|
-
configName: dev.assetPrefix
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.assetPrefix
|
|
@@ -10,9 +9,9 @@ configName: dev.assetPrefix
|
|
|
10
9
|
|
|
11
10
|
此配置项用于设置 **开发模式** 下的静态资源 URL 前缀。
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="dev.assetPrefix" />
|
|
16
15
|
|
|
17
16
|
:::warning
|
|
18
17
|
请注意,该配置项仅适用于开发模式。在生产模式下,请使用 [output.assetPrefix](/configure/app/output/asset-prefix) 配置项进行设置。
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: client
|
|
3
|
-
configName: dev.client
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.client
|
|
@@ -41,6 +40,6 @@ const defaultConfig = {
|
|
|
41
40
|
|
|
42
41
|
配置 Modern.js 在开发过程中注入的 client 代码,可以用于设置热更新对应的 WebSocket URL。
|
|
43
42
|
|
|
44
|
-
import
|
|
43
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
45
44
|
|
|
46
|
-
<
|
|
45
|
+
<RsbuildConfig configName="dev.client" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: hmr
|
|
3
|
-
configName: dev.hmr
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.hmr
|
|
@@ -10,6 +9,6 @@ configName: dev.hmr
|
|
|
10
9
|
|
|
11
10
|
是否开启 Hot Module Replacement 热更新能力。
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="dev.hmr" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: liveReload
|
|
3
|
-
configName: dev.liveReload
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.liveReload
|
|
@@ -10,6 +9,6 @@ configName: dev.liveReload
|
|
|
10
9
|
|
|
11
10
|
是否在源文件变更时自动刷新页面。
|
|
12
11
|
|
|
13
|
-
import
|
|
12
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
14
13
|
|
|
15
|
-
<
|
|
14
|
+
<RsbuildConfig configName="dev.liveReload" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: progressBar
|
|
3
|
-
configName: dev.progressBar
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.progressBar
|
|
@@ -19,6 +18,6 @@ type ProgressBar =
|
|
|
19
18
|
|
|
20
19
|
是否在编译过程中展示进度条。
|
|
21
20
|
|
|
22
|
-
import
|
|
21
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
23
22
|
|
|
24
|
-
<
|
|
23
|
+
<RsbuildConfig configName="dev.progressBar" />
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: setupMiddlewares
|
|
3
|
-
configName: dev.setupMiddlewares
|
|
4
3
|
---
|
|
5
4
|
|
|
6
5
|
# dev.setupMiddlewares
|
|
@@ -51,6 +50,6 @@ type SetupMiddlewares = Array<
|
|
|
51
50
|
|
|
52
51
|
提供执行自定义函数和应用自定义中间件的能力。
|
|
53
52
|
|
|
54
|
-
import
|
|
53
|
+
import RsbuildConfig from '@site-docs/components/rsbuild-config-tooltip';
|
|
55
54
|
|
|
56
|
-
<
|
|
55
|
+
<RsbuildConfig configName="dev.setupMiddlewares" />
|