@modern-js/main-doc 2.22.1 → 2.23.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/docs/en/apis/app/commands.mdx +5 -5
  3. package/docs/en/apis/app/hooks/config/storybook.mdx +24 -0
  4. package/docs/en/apis/app/hooks/src/stories.mdx +1 -1
  5. package/docs/en/apis/app/runtime/core/bootstrap.mdx +5 -5
  6. package/docs/en/apis/app/runtime/core/use-loader.mdx +2 -2
  7. package/docs/en/apis/app/runtime/core/use-module-apps.mdx +2 -2
  8. package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +1 -1
  9. package/docs/en/apis/app/runtime/testing/render.mdx +1 -1
  10. package/docs/en/components/bff-proxy-path-rewrite.mdx +16 -0
  11. package/docs/en/components/bff-proxy-principle.mdx +1 -0
  12. package/docs/en/components/enable-bff-caution.mdx +3 -0
  13. package/docs/en/components/global-proxy-config.mdx +33 -13
  14. package/docs/en/configure/app/bff/enable-handle-web.mdx +5 -5
  15. package/docs/en/configure/app/bff/prefix.mdx +6 -6
  16. package/docs/en/configure/app/bff/proxy.mdx +19 -30
  17. package/docs/en/configure/app/builder-plugins.mdx +1 -1
  18. package/docs/en/configure/app/plugins.mdx +19 -19
  19. package/docs/en/configure/app/runtime/intro.mdx +28 -4
  20. package/docs/en/configure/app/runtime/master-app.mdx +1 -1
  21. package/docs/en/configure/app/runtime/router.mdx +2 -2
  22. package/docs/en/configure/app/server/base-url.mdx +4 -4
  23. package/docs/en/configure/app/server/enable-framework-ext.mdx +4 -4
  24. package/docs/en/configure/app/server/port.mdx +6 -6
  25. package/docs/en/configure/app/server/public-routes.mdx +5 -5
  26. package/docs/en/configure/app/server/routes.mdx +13 -13
  27. package/docs/en/configure/app/server/ssr-by-entries.mdx +4 -4
  28. package/docs/en/configure/app/server/ssr.mdx +5 -5
  29. package/docs/en/configure/app/testing/transformer.mdx +4 -8
  30. package/docs/en/configure/app/usage.mdx +5 -5
  31. package/docs/en/guides/advanced-features/code-split.mdx +15 -14
  32. package/docs/en/guides/advanced-features/compatibility.mdx +3 -24
  33. package/docs/en/guides/advanced-features/rspack-start.mdx +0 -1
  34. package/docs/en/guides/advanced-features/ssr.mdx +2 -2
  35. package/docs/en/guides/advanced-features/testing.mdx +8 -7
  36. package/docs/en/guides/advanced-features/using-storybook.mdx +44 -0
  37. package/docs/en/guides/advanced-features/web-server.mdx +16 -16
  38. package/docs/en/guides/basic-features/alias.mdx +11 -9
  39. package/docs/en/guides/basic-features/env-vars.mdx +14 -14
  40. package/docs/en/guides/basic-features/html.mdx +41 -43
  41. package/docs/en/guides/basic-features/mock.mdx +10 -10
  42. package/docs/en/guides/topic-detail/framework-plugin/implement.mdx +4 -4
  43. package/docs/en/guides/topic-detail/framework-plugin/introduction.mdx +1 -1
  44. package/docs/en/guides/troubleshooting/cli.mdx +13 -13
  45. package/docs/en/guides/troubleshooting/dependencies.mdx +25 -25
  46. package/docs/en/tutorials/first-app/c03-css.mdx +1 -1
  47. package/docs/zh/apis/app/commands.mdx +4 -4
  48. package/docs/zh/apis/app/hooks/config/storybook.mdx +24 -0
  49. package/docs/zh/apis/app/hooks/src/stories.mdx +1 -1
  50. package/docs/zh/apis/app/runtime/testing/render.mdx +1 -1
  51. package/docs/zh/components/bff-proxy-path-rewrite.mdx +16 -0
  52. package/docs/zh/components/bff-proxy-principle.mdx +1 -0
  53. package/docs/zh/components/enable-bff-caution.mdx +4 -0
  54. package/docs/zh/components/global-proxy-config.mdx +35 -11
  55. package/docs/zh/configure/app/bff/enable-handle-web.mdx +3 -3
  56. package/docs/zh/configure/app/bff/prefix.mdx +2 -3
  57. package/docs/zh/configure/app/bff/proxy.mdx +11 -21
  58. package/docs/zh/configure/app/runtime/intro.mdx +1 -1
  59. package/docs/zh/configure/app/server/base-url.mdx +1 -1
  60. package/docs/zh/configure/app/server/public-routes.mdx +2 -2
  61. package/docs/zh/configure/app/server/routes.mdx +2 -2
  62. package/docs/zh/configure/app/server/ssr-by-entries.mdx +3 -3
  63. package/docs/zh/configure/app/server/ssr.mdx +1 -1
  64. package/docs/zh/configure/app/testing/transformer.mdx +6 -3
  65. package/docs/zh/configure/app/usage.mdx +9 -9
  66. package/docs/zh/guides/advanced-features/code-split.mdx +13 -12
  67. package/docs/zh/guides/advanced-features/rspack-start.mdx +0 -1
  68. package/docs/zh/guides/advanced-features/ssr.mdx +2 -2
  69. package/docs/zh/guides/advanced-features/testing.mdx +4 -4
  70. package/docs/zh/guides/advanced-features/using-storybook.mdx +44 -0
  71. package/docs/zh/guides/basic-features/alias.mdx +5 -3
  72. package/docs/zh/guides/basic-features/html.mdx +9 -9
  73. package/docs/zh/guides/basic-features/mock.mdx +2 -2
  74. package/docs/zh/guides/topic-detail/_category_.json +1 -1
  75. package/docs/zh/guides/troubleshooting/cli.mdx +1 -1
  76. package/docs/zh/guides/troubleshooting/dependencies.mdx +1 -1
  77. package/package.json +7 -6
package/CHANGELOG.md CHANGED
@@ -1,5 +1,50 @@
1
1
  # @modern-js/main-doc
2
2
 
3
+ ## 2.23.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [4d4dca0]
8
+ - @modern-js/builder-doc@2.23.1
9
+
10
+ ## 2.23.0
11
+
12
+ ### Patch Changes
13
+
14
+ - 8a93276: docs(main): update basic features alias doc
15
+
16
+ docs(main): 更新基础功能 -- 别名文档
17
+
18
+ - 7e6fb5f: chore: publishConfig add provenance config
19
+
20
+ chore: publishConfig 增加 provenance 配置
21
+
22
+ - 372b950: docs(main): update plugin config doc
23
+
24
+ docs(main): 更新插件配置文档
25
+
26
+ - f28b485: docs(main): update faq doc
27
+
28
+ docs(main): 更新 faq 文档
29
+
30
+ - f264c4a: docs(main): update html template doc
31
+
32
+ docs(main): 更新 HTML 模板文档
33
+
34
+ - 5cba7c4: docs(main): update bff config doc
35
+
36
+ docs(main): 更新 BFF 配置文档
37
+
38
+ - ef865f2: docs(main): update config server doc
39
+
40
+ docs(main): 更新 server 配置文档
41
+
42
+ - 8bb0e14: chore: review code split docs
43
+ chore: 审查代码分割文档
44
+ - Updated dependencies [7e6fb5f]
45
+ - Updated dependencies [692cc0e]
46
+ - @modern-js/builder-doc@2.23.0
47
+
3
48
  ## 2.22.1
4
49
 
5
50
  ### Patch Changes
@@ -112,6 +112,7 @@ For example, add application entry, enable some optional features such as Tailwi
112
112
  Usage: modern new [options]
113
113
 
114
114
  Options:
115
+ --lang <lang> set the language (zh or en) for the new command.
115
116
  -d, --debug using debug mode to log something (default: false)
116
117
  -c, --config <config> set default generator config(json string)
117
118
  --dist-tag <tag> use specified tag version for its generator
@@ -136,7 +137,7 @@ In the project, execute the `new` command to enable features as follows:
136
137
 
137
138
  ```bash
138
139
  $ npx modern new
139
- ? Please select the operation you want: Enable features
140
+ ? Please select the operation you want: Enable Features
140
141
  ? Please select the feature name: (Use arrow keys)
141
142
  ❯ Enable Tailwind CSS
142
143
  Enable BFF
@@ -162,11 +163,10 @@ Usage: modern serve [options]
162
163
  Options:
163
164
  -c --config <config> configuration file path, which can be a relative path or an absolute path
164
165
  -h, --help show command help
165
- --web-only only run web service
166
166
  --api-only only run API service
167
167
  ```
168
168
 
169
- By default, the project will run in `localhost:8080`, you can modify the Server port number with `server.port`:
169
+ By default, the project will run in `localhost:8080`, you can modify the server port number with `server.port`:
170
170
 
171
171
  ```js
172
172
  export default defineConfig({
@@ -180,7 +180,7 @@ export default defineConfig({
180
180
 
181
181
  Execute the command `npx modern upgrade` in the project, by default, dependencies in the `package.json` are updated to the latest version.
182
182
 
183
- ```
183
+ ```bash
184
184
  Usage: modern upgrade [options]
185
185
 
186
186
  Options:
@@ -194,7 +194,7 @@ Options:
194
194
 
195
195
  The `modern inspect` command is used to view the [Modern.js Builder config](https://modernjs.dev/builder/en/guide/basic/builder-config.html) and webpack config of the project.
196
196
 
197
- ```
197
+ ```bash
198
198
  Usage: modern inspect [options]
199
199
 
200
200
  Options:
@@ -2,6 +2,7 @@
2
2
  title: storybook/
3
3
  sidebar_position: 7
4
4
  ---
5
+
5
6
  # storybook/
6
7
 
7
8
  Modern.js supports debugging using Storybook. When configuring Storybook, you need to configure it in the `config/storybook` directory of the project.
@@ -12,3 +13,26 @@ Please refer to [Storybook Configuration](https://storybook.js.org/docs/react/co
12
13
  Enabling the Visual Testing (Storybook) mode function requires running the new command to enable it under the project first.
13
14
 
14
15
  :::
16
+
17
+ #### Example
18
+
19
+ For the webpack configuration of the Storybook Manager app section, you can configure it by adding the `./config/storybook/main.js` file to configure it.
20
+
21
+ ```js
22
+ // ./config/storybook/main.js
23
+
24
+ module.exports = {
25
+ // it controls the Storybook manager app
26
+ managerWebpack: async (config, options) => {
27
+ // update config here
28
+ return config;
29
+ },
30
+ };
31
+ ```
32
+
33
+ ### Limitation
34
+
35
+ There are some limitations when using the `config/storybook` directory for configuration:
36
+
37
+ - The location where the Story file is stored cannot be modified, that is, the `stories` configuration cannot be modified in the `main.js` file.
38
+ - It is not supported to modify Webpack and Babel related configurations in `main.js`, related requirements can be passed through [`tools.webpack`](/configure/app/tools/webpack.html) /[`tools.babel`](/configure/app/tools/babel.html) modify.
@@ -6,7 +6,7 @@ sidebar_position: 7
6
6
 
7
7
  Application project Storybook files.
8
8
 
9
- You can create files in the `*.stories.[tj]sx` format in the project source code directory `src/` as Storybook files.
9
+ You can create files in the `*.stories.(js|jsx|ts|tsx|mdx)` format in the project source code directory `src/` as Storybook files.
10
10
 
11
11
  Run the `npm run dev story` command in the project to use these files to debug relevant content in Storybook.
12
12
 
@@ -3,7 +3,7 @@ title: bootstrap
3
3
  ---
4
4
  # bootstrap
5
5
 
6
- Used to start and mount App, usually without manual calls. This API is only required when using [Custom Bootstrap](/guides/concept/entries#custom-bootstrap).
6
+ Used to start and mount App, usually not manually called. This API is only required when using [Custom Bootstrap](/guides/concept/entries#custom-bootstrap).
7
7
 
8
8
  ## Usage
9
9
 
@@ -32,10 +32,10 @@ type BootStrap<T = unknown> = (
32
32
 
33
33
  ### Input
34
34
 
35
- - `AppComponent`: reactElement instance created by [`createApp`](./create-app).
36
- - `rootId`: DOM root element id to mount, like `"root"`.
37
- - `root`: ReactDOM.create the return value, which is used in the scenario where the root needs to destroy the component outside the bootstrap function.
38
- - `ReactDOM`: ReactDOM object for distinguishing between React 18 and React 17 APIs.
35
+ - `AppComponent`: The ReactElement instance created by [`createApp`](./create-app).
36
+ - `rootId`: DOM root element id to mount, such as `"root"`.
37
+ - `root`: The return value of ReactDOM.createRoot, used for scenarios where the root needs to be destroyed outside of the bootstrap function.
38
+ - `ReactDOM`: The ReactDOM object, used to differentiate between React 18 and React 17 APIs.
39
39
 
40
40
  ## Example
41
41
 
@@ -3,10 +3,10 @@ title: useLoader
3
3
  ---
4
4
  # useLoader
5
5
 
6
- Isomorphic API, usually used to make asynchronous requests. When SSR, the server level uses `useLoader` to prefetch the data, and the browser side also reuses this part of the data.
6
+ `useLoader` is an Isomorphic API, usually used to make asynchronous requests. During Server-Side Rendering (SSR), the server uses `useLoader` to prefetch the data, which is then reused on the client side.
7
7
 
8
8
  :::tip
9
- When using Rspack as the bundler, the useLoader API is not currently supported.
9
+ The `useLoader` API is currently not supported when using Rspack as the bundler.
10
10
  :::
11
11
 
12
12
  ## Usage
@@ -3,7 +3,7 @@ title: useModuleApps
3
3
  ---
4
4
  # useModuleApps
5
5
 
6
- Returns the React components of all micro-front-end sub-applications for freely controlled routing.
6
+ Returns the React components of all micro-front-end sub-applications, allowing for flexible control over routing.
7
7
 
8
8
  ## Usage
9
9
 
@@ -107,7 +107,7 @@ After starting the application in this way, accessing the `/dashboard` route wil
107
107
 
108
108
  ## Load Animation
109
109
 
110
- The transition animation of the component loading process can be customized in the following ways.
110
+ You can customize the transition animation of the component loading process as follows.
111
111
 
112
112
  ```tsx title=App.tsx
113
113
  function App() {
@@ -3,7 +3,7 @@ title: useRuntimeContext
3
3
  ---
4
4
  # useRuntimeContext
5
5
 
6
- This function is mainly used to get the runtime context and can only be used in function components.
6
+ Used to get the runtime context and can only be used in function components.
7
7
 
8
8
  ## Usage
9
9
 
@@ -41,7 +41,7 @@ function render(ui: React.ReactElement<any>, options: Options): RenderResult;
41
41
  - `options`: render options.
42
42
  - `container`: the dom which component mounted. by default create a `div` element, and auto append to `document.body`. the default value is `document.body.append(document.createElement('div'))`.
43
43
  - `baseElement`: Used to specify the `basename` used in `queries`. If `container` is specified, the default value is the value of `container`, otherwise it is `document.body`.
44
- - `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://reactjs.org/docs/react-dom.html#hydrate) rendering component is used. The default value is `false`.
44
+ - `hydrate`: If set to `true`, the [ReactDOM.hydrate](https://react.dev/reference/react-dom/hydrate) rendering component is used. The default value is `false`.
45
45
  - `wrapper`: a react component that can be used to customize rendering logic.
46
46
  - `queries`: customize some own `queries`.
47
47
 
@@ -0,0 +1,16 @@
1
+ Path rewriting can also be performed here, such as proxying the request sent to `localhost:8080/api/topics` to `https://cnodejs.org/api/v1/topics`.
2
+
3
+ ```js title="modern.server-runtime.config.js"
4
+ import { defineConfig } from '@modern-js/app-tools/server';
5
+ export default defineConfig({
6
+ bff: {
7
+ proxy: {
8
+ '/api': {
9
+ target: 'https://cnodejs.org',
10
+ pathRewrite: { '/api/topics': '/api/v1/topics' },
11
+ changeOrigin: true,
12
+ },
13
+ },
14
+ },
15
+ });
16
+ ```
@@ -0,0 +1 @@
1
+ BFF Proxy uses the powerful [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware). For more advanced usage, please refer to its [documentation](https://github.com/chimurai/http-proxy-middleware#options).
@@ -0,0 +1,3 @@
1
+ :::caution
2
+ Please enable BFF functionality in the current application project root directory using [new](/apis/app/commands#modern-new) first.
3
+ :::
@@ -1,16 +1,37 @@
1
1
  - **Type:** `string | Object`
2
2
  - **Default:** `null`
3
3
 
4
- When this option is configured, the development environment will start a global proxy, similar to [Fiddler](https://www.telerik.com/fiddler), [Charles](https://www.charlesproxy.com/) and other web proxy debugging tools, which can be used to view, modify HTTP/HTTPS requests, responses, and can also be used as a proxy server.
4
+ This option is used to configure a global proxy based on [whistle](https://wproxy.org/whistle/) in the development environment, which can be used to view and modify HTTP/HTTPS requests, responses, and can also be used as a proxy server.
5
5
 
6
- :::tip
7
- Using this option requires advance installation `@modern-js/plugin-proxy`.
6
+ ### Register Plugin
8
7
 
9
- :::
8
+ Before using this option, you need to install and register the `@modern-js/plugin-proxy` plugin:
9
+
10
+ ```bash
11
+ # npm
12
+ npm add @modern-js/plugin-proxy -D
13
+
14
+ # yarn
15
+ yarn add @modern-js/plugin-proxy -D
16
+
17
+ # pnpm
18
+ pnpm add @modern-js/plugin-proxy -D
19
+ ```
20
+
21
+ After the installation, please register the plugin in the `modern.config.ts` file:
22
+
23
+ ```ts title="modern.config.ts"
24
+ import appTools, { defineConfig } from '@modern-js/app-tools';
25
+ import proxyPlugin from '@modern-js/plugin-proxy';
10
26
 
11
- ### Object
27
+ export default defineConfig({
28
+ plugins: [appTools(), proxyPlugin()],
29
+ });
30
+ ```
12
31
 
13
- Using this option requires that the value of `Object` be installed in advance, the `key` of the object corresponds to the matching `pattern`, and the `value` of the object corresponds to the matching `target`.
32
+ ### Object Type
33
+
34
+ When the value of `dev.proxy` is object type, the `key` of the object corresponds to the matching `pattern`, and the `value` of the object corresponds to the matching `target`.
14
35
 
15
36
  Example:
16
37
 
@@ -26,9 +47,11 @@ export default defineConfig({
26
47
  });
27
48
  ```
28
49
 
29
- ### String
50
+ Please refer to [whistle - Matching Patterns](https://wproxy.org/whistle/pattern.html) for detailed usage.
51
+
52
+ ### String Type
30
53
 
31
- When the value is `string`, it can be used to specify a separate proxy file, for example:
54
+ When the value of `dev.proxy` is string type, it can be used to specify a separate proxy file, for example:
32
55
 
33
56
  ```ts title="modern.config.ts"
34
57
  export default defineConfig({
@@ -47,10 +70,7 @@ module.exports = {
47
70
  };
48
71
  ```
49
72
 
50
- :::info
51
- Modern.js global proxy implementation is based on [whistle](https://wproxy.org/whistle/), for more matching patterns, please refer to: [Matching Patterns](https://wproxy.org/whistle/pattern.html)
52
-
53
- :::
73
+ ### Start Proxy
54
74
 
55
75
  Execute `dev`, when the prompt is as follows, the proxy server starts successfully:
56
76
 
@@ -68,7 +88,7 @@ Access the `localhost:8899` to view the Network and configure proxy rules on the
68
88
 
69
89
  ![proxy UI](https://lf3-static.bytednsdoc.com/obj/eden-cn/aphqeh7uhohpquloj/modern-js/docs/dev-proxy.png)
70
90
 
71
- :::caution Caution
91
+ :::info
72
92
  The https agent automatically installs the certificate to obtain root privileges. Please enter the password as prompted. ** The password is only used when the certificate is trusted and will not be leaked or used for other links **.
73
93
 
74
94
  :::
@@ -7,13 +7,13 @@ title: enableHandleWeb
7
7
  - **Type:** `boolean`
8
8
  - **Default:** `false`
9
9
 
10
- :::caution
11
- First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
12
- :::
10
+ import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
13
11
 
14
- By default, the BFF service can only handle requests from the BFF API.
12
+ <EnableBFFCaution />
15
13
 
16
- When this value is set to `true`, page request traffic also goes through the BFF, and the logic built into Modern.js for page rendering defaults to running as the last middleware for the BFF service.
14
+ By default, the BFF service can only handle requests for BFF APIs.
15
+
16
+ When this value is set to `true`, page request will also pass through BFF, and the default logic for page rendering built in Modern.js will run as the last middleware of the BFF service.
17
17
 
18
18
  ```ts title="modern.config.ts"
19
19
  export default defineConfig({
@@ -7,18 +7,18 @@ sidebar_label: prefix
7
7
  - **Type:** `string`
8
8
  - **Default:** `/api`
9
9
 
10
- :::caution
11
- First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
12
- :::
10
+ import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
13
11
 
14
- By default, the route access BFF prefix's directory is `/api`, with the following directory structure:
12
+ <EnableBFFCaution />
13
+
14
+ By default, the prefix for accessing routes in the BFF API directory is `/api`, as shown in the following directory structure:
15
15
 
16
16
  ```bash
17
17
  api
18
18
  └── hello.ts
19
19
  ```
20
20
 
21
- The corresponding route for `api/hello.ts` access is `localhost:8080/api/hello`.
21
+ The route corresponding to `api/hello.ts` when accessed is `localhost:8080/api/hello`.
22
22
 
23
23
  This configuration option can modify the default route prefix:
24
24
 
@@ -30,4 +30,4 @@ export default defineConfig({
30
30
  });
31
31
  ```
32
32
 
33
- The corresponding `api/hello.ts` access route is `localhost:8080/api-demo/hello`.
33
+ The corresponding route for `api/hello.ts` when accessed is `localhost:8080/api-demo/hello`.
@@ -7,16 +7,13 @@ sidebar_label: proxy
7
7
  - **Type:** `Record<string, string>`
8
8
  - **Default:** `{}`
9
9
 
10
- :::caution Caution
11
- First you need to enable the "BFF" function using [new](/apis/app/commands#modern-new) command.
10
+ import EnableBFFCaution from "@site-docs-en/components/enable-bff-caution";
12
11
 
13
- :::
14
-
15
- With simple configuration, no code is required, Modern.js automatically forwards requests. Requests sent to Modern.js BFF server are proxied to the specified service.
12
+ <EnableBFFCaution />
16
13
 
17
- BFF Proxy uses the powerful [http-proxy-middleware](https://github.com/chimurai/http-proxy-middleware), and if you need more advanced usage, you can check its [documentation](https://github.com/chimurai/http-proxy-middleware#options).
14
+ With simple configuration, Modern.js can automatically proxy requests sent to the BFF server to the specified service.
18
15
 
19
- Add the following configuration to `modern.server-runtime.config.ts`, you can turn on the proxy:
16
+ Add the following configuration to `modern.server-runtime.config.js` to enable proxy:
20
17
 
21
18
  ```ts title="modern.server-runtime.config.ts"
22
19
  import { defineConfig } from '@modern-js/app-tools/server';
@@ -29,41 +26,31 @@ export default defineConfig({
29
26
  });
30
27
  ```
31
28
 
32
- Assuming that the starting Modern.js BFF server's service address is `localhost:8080`, all requests whose path starts with `api` will be intercepted, such as requests sent to `localhost:8080/api/v1/topics` will be proxied to `https://cnodejs.org/api/v1/topics`.
29
+ Assuming the address of Modern.js BFF server is `localhost:8080`, all requests starting with `api` will be proxied to `https://cnodejs.org`, for example, the request to `localhost:8080/api/v1/topics` will be proxied to `https://cnodejs.org/api/v1/topics`.
33
30
 
34
- You can do path rewriting, such as proxying requests sent to `localhost:8080/api/topics` to `https://cnodejs.org/api/v1/topics`.
31
+ import BFFProxyPathRewrite from "@site-docs/components/bff-proxy-path-rewrite";
35
32
 
36
- ```js title="modern.server-runtime.config.js"
37
- import { defineConfig } from '@modern-js/app-tools/server';
38
- export default defineConfig({
39
- bff: {
40
- proxy: {
41
- '/api': {
42
- target: 'https://cnodejs.org',
43
- pathRewrite: { '/api/topics': '/api/v1/topics' },
44
- changeOrigin: true,
45
- },
46
- },
47
- },
48
- });
49
- ```
33
+ <BFFProxyPathRewrite />
50
34
 
51
- Unlike [dev.proxy](/configure/app/dev/proxy), the proxy described in this section only works on requests entering the BFF/API service; at the same time, this configuration can be used not only in the development environment, but also in the production environment. The corresponding request will also be proxied in the production environment.
35
+ Unlike [dev.proxy](/configure/app/dev/proxy), the proxy here only applies to requests entering the BFF/API service; at the same time, this configuration can not only be used in the development environment, but also proxies corresponding requests in the production environment.
52
36
 
53
- ## Common usage
37
+ import BFFProxyPrinciple from "@site-docs/components/bff-proxy-principle";
54
38
 
55
- ### Solve interface cross-domain problems
39
+ <BFFProxyPrinciple />
56
40
 
57
- In the process of project development, because web pages and interface services are not deployed under the same domain name, cross-domain problems are often encountered.
41
+ ## Common Usage
58
42
 
59
- There are many ways to solve cross-domain problems, and here we use `bff.proxy` to easily solve cross-domain problems.
43
+ ### Solving Cross-Domain Issues for APIs
44
+
45
+ During project development, cross-domain issues are often encountered because web pages and API services are not deployed under the same domain name.
46
+ There are many ways to solve cross-domain issues, and here we can easily solve them using `bff.proxy`.
60
47
 
61
48
  :::info
62
- In BFF proxy mode, if you do not need to write the BFF interface, the API directory can be deleted; at this time, BFF proxy will still be enabled.
49
+ Under BFF proxy mode, if you don't need to write BFF code, the API directory can be deleted; BFF proxy will still be enabled.
63
50
 
64
51
  :::
65
52
 
66
- As shown below, in the `modern.server-runtime.config.js`, write the following configuration; we send all web pages to the same domain that request proxies starting with `/api` to another domain's service.
53
+ As shown below, the following configuration in `modern.server-runtime.config.ts` will proxy all web page requests starting with `/api` to a service on another domain with the same domain.
67
54
 
68
55
  ```ts title="modern.server-runtime.config.ts"
69
56
  export default defineServerConfig({
@@ -74,3 +61,5 @@ export default defineServerConfig({
74
61
  },
75
62
  };
76
63
  ```
64
+
65
+
@@ -17,7 +17,7 @@ This option **is used to configure the Modern.js Builder plugins**. If you need
17
17
 
18
18
  - Use [plugins](/configure/app/builder-plugins) to configure Modern.js framework plugins.
19
19
  - Use [tools.webpack](/configure/app/tools/webpack) or [tools.webpackChain](/configure/app/tools/webpack-chain) to configure webpack plugins.
20
- - Use [tools.babel](/configure/app/tools/babel) to configure babel plugins.
20
+ - Use [tools.babel](/configure/app/tools/babel) to configure Babel plugins.
21
21
 
22
22
  ## When to use
23
23
 
@@ -9,39 +9,39 @@ sidebar_position: 9
9
9
 
10
10
  Used to configure custom Modern.js framework plugins.
11
11
 
12
- For the way to write custom plugins, please refer to [How to Write Plugins](/guides/topic-detail/framework-plugin/implement).
12
+ Refer to [How to Develop Plugins](/guides/topic-detail/framework-plugin/implement) for how to write custom plugins.
13
13
 
14
- ## Precautions
14
+ ## Note
15
15
 
16
- This config **is used to configure the Modern.js framework plugin**. If you need to configure other types of plugins, please select the corresponding configs:
16
+ This option is used to configure framework plugins. If you need to configure other types of plugins, please choose the corresponding configuration method:
17
17
 
18
- - Use [builderPlugins](/configure/app/builder-plugins) to configure Modern.js Builder plugins.
19
- - Use [tools.webpack](/configure/app/tools/webpack) or [tools.webpackChain](/configure/app/tools/webpack-chain) to configure webpack plugins.
20
- - Use [tools.babel](/configure/app/tools/babel) to configure babel plugins.
18
+ - To configure Modern.js Builder plugins, use the [builderPlugins](/configure/app/builder-plugins) option.
19
+ - To configure webpack plugins, use the [tools.webpack](/configure/app/tools/webpack) or [tools.webpackChain](/configure/app/tools/webpack-chain) options.
20
+ - To configure Babel plugins, use the [tools.babel](/configure/app/tools/babel) option.
21
21
 
22
- ## Plugin type
22
+ ## Plugin types
23
23
 
24
- There are three different type of framework plugins built into the Modern.js:
24
+ Modern.js has three types of plugins:
25
25
 
26
- - `CLI Plugin`, for local development, compilation and build phases, can extend various capabilities on the command line and compilation phases.
27
- - `Server Plugin`, for server-level.
28
- - `Runtime Plugin`, for runtime.
26
+ - `CLI plugins`, applicable to local development, compilation and construction stages, can extend various capabilities in the command line and compilation stages.
27
+ - `Server plugins`, applicable to the server.
28
+ - `Runtime plugins`, applicable to the front-end runtime.
29
29
 
30
- The ability to customize CLI plugins is currently open Modern.js, and the Server plugin and Runtime plugin will be available in the future.
30
+ Currently, Modern.js has opened up the ability to customize CLI plugins, and Server plugins and Runtime plugins will be opened up later.
31
31
 
32
32
  ## Plugin execution order
33
33
 
34
- By default, custom plugins are executed sequentially in the order of an array of `plugins`, Modern.js built-in plugins are executed earlier than custom plugins.
34
+ By default, custom plugins are executed in the order of the `plugins` array, and the execution time of built-in Modern.js plugins is earlier than that of custom plugins.
35
35
 
36
- When the plugin uses related fields that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields, see [Relationship between plugins](/guides/topic-detail/framework-plugin/relationship).
36
+ When the plugin sets options that control the order, such as `pre` and `post`, the execution order will be adjusted based on the declared fields. Refer to [Relationship between plugins](/guides/topic-detail/framework-plugin/relationship) for more information.
37
37
 
38
38
  ## Example
39
39
 
40
- Below is an example of using the CLI plugin.
40
+ The following is an example of using CLI plugins.
41
41
 
42
- ### Using plugins on npm
42
+ ### Use plugins on npm
43
43
 
44
- To use the plugin on npm, you need to install the plugin through the package manager and import it.
44
+ To use plugins from npm registry, you need to first install the plugins , and import them in `modern.config.ts`.
45
45
 
46
46
  ```ts title="modern.config.ts"
47
47
  import myPlugin from 'my-plugin';
@@ -53,7 +53,7 @@ export default defineConfig({
53
53
 
54
54
  ### Use local plugins
55
55
 
56
- Using the plugin in the local code repository, you can import it directly through the relative path import.
56
+ To use local plugins, import them directly using a relative path.
57
57
 
58
58
  ```ts title="modern.config.ts"
59
59
  import myPlugin from './config/plugin/myPlugin';
@@ -65,7 +65,7 @@ export default defineConfig({
65
65
 
66
66
  ### Plugin configuration
67
67
 
68
- If the plugin provides some custom configuration options, you can pass in the configuration through the parameters of the plugin function.
68
+ If the plugin provides some custom configuration options, they can be passed in as parameters to the plugin function.
69
69
 
70
70
  ```ts title="modern.config.ts"
71
71
  import myPlugin from 'my-plugin';
@@ -5,7 +5,7 @@ sidebar_position: 1
5
5
 
6
6
  # Overview
7
7
 
8
- This section describes the configuration of the Runtime plugin.
8
+ This section describes configuration of the Runtime plugin.
9
9
 
10
10
  ## Configuration
11
11
 
@@ -32,13 +32,34 @@ export default defineConfig({
32
32
 
33
33
  #### DefineConfig
34
34
 
35
- Configure use [`defineConfig`](/apis/app/runtime/app/define-config) API:
35
+ Configure using [`defineConfig`](/apis/app/runtime/app/define-config) API:
36
36
 
37
37
  :::info
38
- When there is a function in the runtime configuration, it can only be configured in this way.
38
+ When there is a function in the runtime configuration, it can only be configured this way.
39
39
 
40
40
  :::
41
41
 
42
+ import { Tabs, Tab as TabItem } from "@theme";
43
+
44
+ <Tabs>
45
+ <TabItem value="layout" label="Conventional Routing" default>
46
+
47
+ ```tsx title="src/routes/layout.tsx"
48
+ import type { AppConfig } from '@modern-js/runtime';
49
+
50
+ export const config = (): AppConfig => {
51
+ return {
52
+ router: {
53
+ supportHtml5History: false
54
+ }
55
+ }
56
+ };
57
+ ```
58
+
59
+ </TabItem>
60
+
61
+ <TabItem value="app" label="Self-controlled Routing">
62
+
42
63
  ```ts title="src/App.tsx"
43
64
  import { defineConfig } from '@modern-js/runtime';
44
65
 
@@ -55,6 +76,9 @@ defineConfig(App, {
55
76
  export default App;
56
77
  ```
57
78
 
79
+ </TabItem>
80
+ </Tabs>
81
+
58
82
  :::info
59
83
  Using runtime configuration, you can solve the problem that runtime plugin configuration needs to be at runtime to get specific content.
60
84
 
@@ -63,7 +87,7 @@ Runtime plugin runtime configuration and configuration directly in `modern.confi
63
87
  :::
64
88
 
65
89
  :::warning
66
- defineConfig can only define the specific configuration content of the Runtime plugin. To confirm whether to enable the plugin, it needs to be determined through the configuration in `modernConfig` in `package.json` or `modern.config.ts`.
90
+ The `defineConfig` API only accepts the specific configuration of Runtime plugins. Enabling the plugin is determined through `modern.config.ts` configuration."
67
91
 
68
92
  :::
69
93
 
@@ -35,6 +35,6 @@ interface AppInfo {
35
35
 
36
36
  ### Other Config
37
37
 
38
- Under the `masterApp` configuration, developers can pass through the configuration items of Garfish.
38
+ In the `masterApp` configuration, developers can pass through options supported by Garfish
39
39
 
40
40
  All supported configuration items [see here](https://garfishjs.org/api/run/#%E5%8F%82%E6%95%B0).
@@ -11,14 +11,14 @@ import RouterLegacyTip from "@site-docs-en/components/router-legacy-tip"
11
11
  - **Type:** `boolean | Object`
12
12
  - **Default:** `false`
13
13
 
14
- When `router` is enabled, routing management of conventional routes provided by Modern.js is supported. Based on [React Router 6](https://reactrouter.com/).
14
+ When enabled, the router option provides routing management for Modern.js conventional routes. It is based on [React Router 6](https://reactrouter.com/).
15
15
 
16
16
  ## basename
17
17
 
18
18
  - **Type:** `string`
19
19
  - **Default:** ``
20
20
 
21
- The basename of the app for situations where you can't deploy to the root of the domain, but a sub directory.
21
+ The basename option specifies the subpath where the app is deployed, for situations where it cannot be deployed to the root domain.
22
22
 
23
23
  ## supportHtml5History
24
24