@modern-js/app-tools 3.7.0 → 3.8.0

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.
Files changed (306) hide show
  1. package/bin/modern-bundle-docs.js +7 -0
  2. package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
  3. package/dist/cjs/bundleDocs.js +114 -0
  4. package/dist/cjs/commands/build.js +2 -1
  5. package/dist/cjs/commands/deploy.js +4 -2
  6. package/dist/cjs/commands/index.js +0 -4
  7. package/dist/cjs/config/default.js +2 -0
  8. package/dist/cjs/index.js +52 -14
  9. package/dist/cjs/plugins/analyze/index.js +2 -2
  10. package/dist/cjs/plugins/analyze/utils.js +3 -2
  11. package/dist/cjs/plugins/initialize/index.js +4 -3
  12. package/dist/cjs/plugins/serverBuild.js +3 -2
  13. package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
  14. package/dist/esm/bundleDocs.mjs +62 -0
  15. package/dist/esm/commands/build.mjs +2 -1
  16. package/dist/esm/commands/deploy.mjs +4 -2
  17. package/dist/esm/commands/index.mjs +0 -4
  18. package/dist/esm/config/default.mjs +2 -0
  19. package/dist/esm/index.mjs +15 -1
  20. package/dist/esm/plugins/analyze/index.mjs +2 -2
  21. package/dist/esm/plugins/analyze/utils.mjs +3 -2
  22. package/dist/esm/plugins/initialize/index.mjs +4 -3
  23. package/dist/esm/plugins/serverBuild.mjs +3 -2
  24. package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
  25. package/dist/esm-node/bundleDocs.mjs +63 -0
  26. package/dist/esm-node/commands/build.mjs +2 -1
  27. package/dist/esm-node/commands/deploy.mjs +4 -2
  28. package/dist/esm-node/commands/index.mjs +0 -4
  29. package/dist/esm-node/config/default.mjs +2 -0
  30. package/dist/esm-node/index.mjs +15 -1
  31. package/dist/esm-node/plugins/analyze/index.mjs +2 -2
  32. package/dist/esm-node/plugins/analyze/utils.mjs +3 -2
  33. package/dist/esm-node/plugins/initialize/index.mjs +4 -3
  34. package/dist/esm-node/plugins/serverBuild.mjs +3 -2
  35. package/dist/types/bundleDocs.d.ts +20 -0
  36. package/dist/types/commands/deploy.d.ts +2 -1
  37. package/dist/types/index.d.ts +4 -1
  38. package/dist/types/plugins/analyze/utils.d.ts +1 -1
  39. package/dist/types/types/config/dev.d.ts +6 -0
  40. package/docs/apis/app/commands.md +241 -0
  41. package/docs/apis/app/hooks/api/lambda.md +9 -0
  42. package/docs/apis/app/hooks/config/favicon.md +24 -0
  43. package/docs/apis/app/hooks/config/html.md +5 -0
  44. package/docs/apis/app/hooks/config/icon.md +24 -0
  45. package/docs/apis/app/hooks/config/mock.md +6 -0
  46. package/docs/apis/app/hooks/config/public.md +26 -0
  47. package/docs/apis/app/hooks/config/upload.md +50 -0
  48. package/docs/apis/app/hooks/modern-config.md +5 -0
  49. package/docs/apis/app/hooks/server/server.md +5 -0
  50. package/docs/apis/app/hooks/shared.md +3 -0
  51. package/docs/apis/app/hooks/src/app.md +30 -0
  52. package/docs/apis/app/hooks/src/entry.md +34 -0
  53. package/docs/apis/app/hooks/src/entry.server.md +51 -0
  54. package/docs/apis/app/hooks/src/modern.runtime.md +5 -0
  55. package/docs/apis/app/hooks/src/routes.md +86 -0
  56. package/docs/apis/app/hooks/src/server.md +3 -0
  57. package/docs/apis/app/runtime/bff/use-hono-context.md +27 -0
  58. package/docs/apis/app/runtime/core/create-root.md +19 -0
  59. package/docs/apis/app/runtime/core/render.md +39 -0
  60. package/docs/apis/app/runtime/core/runtime-context.md +156 -0
  61. package/docs/apis/app/runtime/router/router.md +280 -0
  62. package/docs/apis/app/runtime/ssr/no-ssr.md +35 -0
  63. package/docs/apis/app/runtime/ssr/renderStreaming.md +67 -0
  64. package/docs/apis/app/runtime/ssr/renderString.md +60 -0
  65. package/docs/apis/app/runtime/ssr/requestHandler.md +44 -0
  66. package/docs/apis/app/runtime/utility/css-in-js.md +40 -0
  67. package/docs/apis/app/runtime/utility/head.md +35 -0
  68. package/docs/apis/app/runtime/utility/loadable.md +82 -0
  69. package/docs/community/blog/2022-0708-updates.md +91 -0
  70. package/docs/community/blog/2022-0910-updates.md +76 -0
  71. package/docs/community/blog/overview.md +63 -0
  72. package/docs/community/blog/v2-release-note.md +238 -0
  73. package/docs/community/blog/v3-release-note.md +622 -0
  74. package/docs/community/contributing-guide.md +253 -0
  75. package/docs/community/releases.md +27 -0
  76. package/docs/community/showcase.md +34 -0
  77. package/docs/community/team.md +14 -0
  78. package/docs/configure/app/bff/cross-project.md +20 -0
  79. package/docs/configure/app/bff/prefix.md +29 -0
  80. package/docs/configure/app/builder-plugins.md +66 -0
  81. package/docs/configure/app/dev/asset-prefix.md +13 -0
  82. package/docs/configure/app/dev/before-start-url.md +17 -0
  83. package/docs/configure/app/dev/client.md +41 -0
  84. package/docs/configure/app/dev/hmr.md +10 -0
  85. package/docs/configure/app/dev/host.md +18 -0
  86. package/docs/configure/app/dev/https.md +77 -0
  87. package/docs/configure/app/dev/lazy-compilation.md +39 -0
  88. package/docs/configure/app/dev/live-reload.md +10 -0
  89. package/docs/configure/app/dev/mock-dir.md +31 -0
  90. package/docs/configure/app/dev/progress-bar.md +19 -0
  91. package/docs/configure/app/dev/server.md +124 -0
  92. package/docs/configure/app/dev/setup-middlewares.md +32 -0
  93. package/docs/configure/app/dev/start-url.md +48 -0
  94. package/docs/configure/app/dev/watch-files.md +27 -0
  95. package/docs/configure/app/dev/write-to-disk.md +10 -0
  96. package/docs/configure/app/experiments/source-build.md +31 -0
  97. package/docs/configure/app/html/app-icon.md +28 -0
  98. package/docs/configure/app/html/crossorigin.md +10 -0
  99. package/docs/configure/app/html/favicon.md +16 -0
  100. package/docs/configure/app/html/inject.md +10 -0
  101. package/docs/configure/app/html/meta.md +24 -0
  102. package/docs/configure/app/html/mount-id.md +10 -0
  103. package/docs/configure/app/html/output-structure.md +10 -0
  104. package/docs/configure/app/html/script-loading.md +10 -0
  105. package/docs/configure/app/html/tags.md +15 -0
  106. package/docs/configure/app/html/template-parameters.md +33 -0
  107. package/docs/configure/app/html/template.md +10 -0
  108. package/docs/configure/app/html/title.md +18 -0
  109. package/docs/configure/app/output/asset-prefix.md +11 -0
  110. package/docs/configure/app/output/assets-retry.md +77 -0
  111. package/docs/configure/app/output/charset.md +10 -0
  112. package/docs/configure/app/output/clean-dist-path.md +16 -0
  113. package/docs/configure/app/output/convert-to-rem.md +79 -0
  114. package/docs/configure/app/output/copy.md +10 -0
  115. package/docs/configure/app/output/css-modules.md +48 -0
  116. package/docs/configure/app/output/data-uri-limit.md +26 -0
  117. package/docs/configure/app/output/disable-css-module-extension.md +55 -0
  118. package/docs/configure/app/output/disable-inline-runtime-chunk.md +41 -0
  119. package/docs/configure/app/output/disable-svgr.md +16 -0
  120. package/docs/configure/app/output/disable-ts-checker.md +49 -0
  121. package/docs/configure/app/output/dist-path.md +43 -0
  122. package/docs/configure/app/output/enable-asset-manifest.md +36 -0
  123. package/docs/configure/app/output/enable-css-module-tsdeclaration.md +28 -0
  124. package/docs/configure/app/output/enable-inline-route-manifests.md +16 -0
  125. package/docs/configure/app/output/externals.md +20 -0
  126. package/docs/configure/app/output/filename-hash.md +10 -0
  127. package/docs/configure/app/output/filename.md +55 -0
  128. package/docs/configure/app/output/inject-styles.md +10 -0
  129. package/docs/configure/app/output/inline-scripts.md +29 -0
  130. package/docs/configure/app/output/inline-styles.md +29 -0
  131. package/docs/configure/app/output/legal-comments.md +18 -0
  132. package/docs/configure/app/output/minify.md +22 -0
  133. package/docs/configure/app/output/override-browserslist.md +22 -0
  134. package/docs/configure/app/output/polyfill.md +12 -0
  135. package/docs/configure/app/output/source-map.md +30 -0
  136. package/docs/configure/app/output/split-route-chunks.md +16 -0
  137. package/docs/configure/app/output/ssg.md +81 -0
  138. package/docs/configure/app/output/ssgByEntries.md +90 -0
  139. package/docs/configure/app/output/svg-default-export.md +30 -0
  140. package/docs/configure/app/output/temp-dir.md +20 -0
  141. package/docs/configure/app/performance/build-cache.md +39 -0
  142. package/docs/configure/app/performance/chunk-split.md +40 -0
  143. package/docs/configure/app/performance/dns-prefetch.md +15 -0
  144. package/docs/configure/app/performance/preconnect.md +16 -0
  145. package/docs/configure/app/performance/prefetch.md +21 -0
  146. package/docs/configure/app/performance/preload.md +23 -0
  147. package/docs/configure/app/performance/print-file-size.md +40 -0
  148. package/docs/configure/app/performance/profile.md +10 -0
  149. package/docs/configure/app/performance/remove-console.md +10 -0
  150. package/docs/configure/app/performance/remove-moment-locale.md +10 -0
  151. package/docs/configure/app/plugins.md +59 -0
  152. package/docs/configure/app/resolve/alias-strategy.md +10 -0
  153. package/docs/configure/app/resolve/alias.md +9 -0
  154. package/docs/configure/app/resolve/condition-names.md +13 -0
  155. package/docs/configure/app/resolve/dedupe.md +9 -0
  156. package/docs/configure/app/resolve/extensions.md +13 -0
  157. package/docs/configure/app/runtime/0-intro.md +58 -0
  158. package/docs/configure/app/runtime/plugins.md +58 -0
  159. package/docs/configure/app/runtime/router.md +35 -0
  160. package/docs/configure/app/security/check-syntax.md +69 -0
  161. package/docs/configure/app/security/nonce.md +15 -0
  162. package/docs/configure/app/security/sri.md +20 -0
  163. package/docs/configure/app/server/base-url.md +26 -0
  164. package/docs/configure/app/server/port.md +18 -0
  165. package/docs/configure/app/server/public-routes.md +22 -0
  166. package/docs/configure/app/server/routes.md +86 -0
  167. package/docs/configure/app/server/rsc.md +26 -0
  168. package/docs/configure/app/server/ssr-by-entries.md +25 -0
  169. package/docs/configure/app/server/ssr.md +78 -0
  170. package/docs/configure/app/server/tsconfig-path.md +59 -0
  171. package/docs/configure/app/source/alias-strategy.md +14 -0
  172. package/docs/configure/app/source/alias.md +23 -0
  173. package/docs/configure/app/source/config-dir.md +20 -0
  174. package/docs/configure/app/source/decorators.md +25 -0
  175. package/docs/configure/app/source/define.md +16 -0
  176. package/docs/configure/app/source/disable-default-entries.md +28 -0
  177. package/docs/configure/app/source/enable-async-entry.md +54 -0
  178. package/docs/configure/app/source/enable-async-pre-entry.md +26 -0
  179. package/docs/configure/app/source/entries-dir.md +35 -0
  180. package/docs/configure/app/source/entries.md +179 -0
  181. package/docs/configure/app/source/exclude.md +10 -0
  182. package/docs/configure/app/source/global-vars.md +106 -0
  183. package/docs/configure/app/source/include.md +36 -0
  184. package/docs/configure/app/source/main-entry-name.md +24 -0
  185. package/docs/configure/app/source/pre-entry.md +10 -0
  186. package/docs/configure/app/source/react-compiler.md +68 -0
  187. package/docs/configure/app/source/transform-import.md +27 -0
  188. package/docs/configure/app/split-chunks.md +17 -0
  189. package/docs/configure/app/tools/autoprefixer.md +44 -0
  190. package/docs/configure/app/tools/bundler-chain.md +26 -0
  191. package/docs/configure/app/tools/css-extract.md +33 -0
  192. package/docs/configure/app/tools/css-loader.md +17 -0
  193. package/docs/configure/app/tools/dev-server.md +113 -0
  194. package/docs/configure/app/tools/html-plugin.md +41 -0
  195. package/docs/configure/app/tools/less.md +81 -0
  196. package/docs/configure/app/tools/lightningcss-loader.md +35 -0
  197. package/docs/configure/app/tools/minify-css.md +53 -0
  198. package/docs/configure/app/tools/postcss.md +34 -0
  199. package/docs/configure/app/tools/rspack.md +10 -0
  200. package/docs/configure/app/tools/sass.md +78 -0
  201. package/docs/configure/app/tools/style-loader.md +10 -0
  202. package/docs/configure/app/tools/swc.md +65 -0
  203. package/docs/configure/app/tools/ts-checker.md +109 -0
  204. package/docs/configure/app/usage.md +276 -0
  205. package/docs/guides/advanced-features/bff/cross-project.md +109 -0
  206. package/docs/guides/advanced-features/bff/extend-server.md +120 -0
  207. package/docs/guides/advanced-features/bff/frameworks.md +124 -0
  208. package/docs/guides/advanced-features/bff/function.md +314 -0
  209. package/docs/guides/advanced-features/bff/operators.md +554 -0
  210. package/docs/guides/advanced-features/bff/sdk.md +116 -0
  211. package/docs/guides/advanced-features/bff/upload.md +101 -0
  212. package/docs/guides/advanced-features/bff.md +18 -0
  213. package/docs/guides/advanced-features/build-performance.md +130 -0
  214. package/docs/guides/advanced-features/compatibility.md +120 -0
  215. package/docs/guides/advanced-features/international/advanced.md +128 -0
  216. package/docs/guides/advanced-features/international/api.md +231 -0
  217. package/docs/guides/advanced-features/international/best-practices.md +286 -0
  218. package/docs/guides/advanced-features/international/configuration.md +227 -0
  219. package/docs/guides/advanced-features/international/locale-detection.md +126 -0
  220. package/docs/guides/advanced-features/international/quick-start.md +128 -0
  221. package/docs/guides/advanced-features/international/resource-loading.md +154 -0
  222. package/docs/guides/advanced-features/international/routing.md +130 -0
  223. package/docs/guides/advanced-features/international.md +27 -0
  224. package/docs/guides/advanced-features/low-level.md +46 -0
  225. package/docs/guides/advanced-features/page-performance/code-split.md +77 -0
  226. package/docs/guides/advanced-features/page-performance/inline-assets.md +159 -0
  227. package/docs/guides/advanced-features/page-performance/optimize-bundle.md +97 -0
  228. package/docs/guides/advanced-features/page-performance/react-compiler.md +69 -0
  229. package/docs/guides/advanced-features/server-monitor/logger.md +41 -0
  230. package/docs/guides/advanced-features/server-monitor/metrics.md +58 -0
  231. package/docs/guides/advanced-features/server-monitor/monitors.md +242 -0
  232. package/docs/guides/advanced-features/source-build.md +164 -0
  233. package/docs/guides/advanced-features/web-server.md +288 -0
  234. package/docs/guides/basic-features/alias.md +102 -0
  235. package/docs/guides/basic-features/css/css-in-js.md +72 -0
  236. package/docs/guides/basic-features/css/css-modules.md +212 -0
  237. package/docs/guides/basic-features/css/css.md +27 -0
  238. package/docs/guides/basic-features/css/tailwindcss.md +27 -0
  239. package/docs/guides/basic-features/data/data-cache.md +510 -0
  240. package/docs/guides/basic-features/data/data-fetch.md +415 -0
  241. package/docs/guides/basic-features/data/data-write.md +227 -0
  242. package/docs/guides/basic-features/debug/mock.md +109 -0
  243. package/docs/guides/basic-features/debug/proxy.md +21 -0
  244. package/docs/guides/basic-features/debug/rsdoctor.md +62 -0
  245. package/docs/guides/basic-features/debug/using-storybook.md +112 -0
  246. package/docs/guides/basic-features/deploy.md +458 -0
  247. package/docs/guides/basic-features/env-vars.md +177 -0
  248. package/docs/guides/basic-features/html.md +255 -0
  249. package/docs/guides/basic-features/output-files.md +141 -0
  250. package/docs/guides/basic-features/render/before-render.md +108 -0
  251. package/docs/guides/basic-features/render/overview.md +47 -0
  252. package/docs/guides/basic-features/render/rsc.md +525 -0
  253. package/docs/guides/basic-features/render/ssg.md +228 -0
  254. package/docs/guides/basic-features/render/ssr-cache.md +201 -0
  255. package/docs/guides/basic-features/render/ssr.md +321 -0
  256. package/docs/guides/basic-features/render/streaming-ssr.md +264 -0
  257. package/docs/guides/basic-features/routes/config-routes.md +426 -0
  258. package/docs/guides/basic-features/routes/routes.md +498 -0
  259. package/docs/guides/basic-features/static-assets/json-files.md +120 -0
  260. package/docs/guides/basic-features/static-assets/svg-assets.md +168 -0
  261. package/docs/guides/basic-features/static-assets/wasm-assets.md +62 -0
  262. package/docs/guides/basic-features/static-assets.md +160 -0
  263. package/docs/guides/basic-features/testing/playwright.md +120 -0
  264. package/docs/guides/basic-features/testing/rstest.md +251 -0
  265. package/docs/guides/concept/builder.md +37 -0
  266. package/docs/guides/concept/entries.md +319 -0
  267. package/docs/guides/concept/server.md +35 -0
  268. package/docs/guides/get-started/ai-coding-agents.md +58 -0
  269. package/docs/guides/get-started/glossary.md +63 -0
  270. package/docs/guides/get-started/introduction.md +36 -0
  271. package/docs/guides/get-started/quick-start.md +236 -0
  272. package/docs/guides/get-started/tech-stack.md +82 -0
  273. package/docs/guides/get-started/upgrade.md +123 -0
  274. package/docs/guides/topic-detail/module-federation/application.md +116 -0
  275. package/docs/guides/topic-detail/module-federation/deploy.md +104 -0
  276. package/docs/guides/topic-detail/module-federation/i18n.md +670 -0
  277. package/docs/guides/topic-detail/module-federation/introduce.md +35 -0
  278. package/docs/guides/topic-detail/module-federation/ssr.md +118 -0
  279. package/docs/guides/topic-detail/module-federation/usage.md +219 -0
  280. package/docs/guides/troubleshooting/builder.md +110 -0
  281. package/docs/guides/troubleshooting/cli.md +35 -0
  282. package/docs/guides/troubleshooting/dependencies.md +119 -0
  283. package/docs/guides/troubleshooting/hmr.md +144 -0
  284. package/docs/guides/upgrade/config.md +963 -0
  285. package/docs/guides/upgrade/entry.md +463 -0
  286. package/docs/guides/upgrade/other.md +183 -0
  287. package/docs/guides/upgrade/overview.md +33 -0
  288. package/docs/guides/upgrade/tailwindcss.md +91 -0
  289. package/docs/guides/upgrade/web-server.md +109 -0
  290. package/docs/index.md +33 -0
  291. package/docs/llms.txt +285 -0
  292. package/docs/plugin/cli-plugins/api.md +573 -0
  293. package/docs/plugin/cli-plugins/life-cycle.md +2 -0
  294. package/docs/plugin/introduction.md +152 -0
  295. package/docs/plugin/official/cli-plugins/plugin-bff.md +5 -0
  296. package/docs/plugin/official/cli-plugins/plugin-ssg.md +5 -0
  297. package/docs/plugin/official/cli-plugins/plugin-styled-components.md +5 -0
  298. package/docs/plugin/official/cli-plugins.md +4 -0
  299. package/docs/plugin/plugin-system.md +238 -0
  300. package/docs/plugin/runtime-plugins/api.md +194 -0
  301. package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
  302. package/docs/plugin/server-plugins/api.md +209 -0
  303. package/docs/plugin/server-plugins/life-cycle.md +13 -0
  304. package/docs/tutorials/examples/csr-auth.md +9 -0
  305. package/docs/tutorials/foundations/introduction.md +16 -0
  306. package/package.json +46 -13
@@ -0,0 +1,31 @@
1
+ # dev.mockDir
2
+
3
+ - **Type:** `string`
4
+ - **Default:** `'./config/mock'`
5
+
6
+ Sets the directory containing the Mock API entry file. Relative paths are
7
+ resolved from the application directory, and absolute paths are also supported.
8
+ Modern.js loads `index.ts` or `index.js` from this directory during development.
9
+
10
+ For example, move the Mock API entry to `mocks/index.ts`:
11
+
12
+ ```js title="modern.config.ts"
13
+ import { defineConfig } from '@modern-js/app-tools';
14
+
15
+ export default defineConfig({
16
+ dev: {
17
+ mockDir: './mocks',
18
+ },
19
+ });
20
+ ```
21
+
22
+ This is also useful in a monorepo when multiple applications share one Mock
23
+ directory:
24
+
25
+ ```js title="modern.config.ts"
26
+ export default defineConfig({
27
+ dev: {
28
+ mockDir: '../../shared/mocks',
29
+ },
30
+ });
31
+ ```
@@ -0,0 +1,19 @@
1
+ # dev.progressBar
2
+
3
+ - **Type:**
4
+
5
+ ```ts
6
+ type ProgressBar =
7
+ | boolean
8
+ | {
9
+ id?: string;
10
+ };
11
+ ```
12
+
13
+ - **Default:** true
14
+
15
+ Whether to display progress bar during compilation.
16
+
17
+ :::info
18
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - dev.progressBar](https://v2.rsbuild.dev/config/dev/progress-bar).
19
+ :::
@@ -0,0 +1,124 @@
1
+ # dev.server
2
+
3
+ - **Type:** `Object`
4
+ - **Default:** `{}`
5
+
6
+ The config of DevServer can be modified through `dev.server`.
7
+
8
+ ### compress
9
+
10
+ - **Type:** `boolean`
11
+ - **Default:** `true`
12
+
13
+ Whether to enable gzip compression for served static assets.
14
+
15
+ If you want to disable the gzip compression, you can set `compress` to `false`:
16
+
17
+ ```ts
18
+ export default {
19
+ dev: {
20
+ server: {
21
+ compress: false,
22
+ },
23
+ },
24
+ };
25
+ ```
26
+
27
+ For more details, please refer to the [Rsbuild - server.compress](https://v2.rsbuild.rs/config/server/compress) documentation.
28
+
29
+ ### headers
30
+
31
+ - **Type:** `Record<string, string>`
32
+ - **Default:** `undefined`
33
+
34
+ Adds headers to all responses.
35
+
36
+ ```js
37
+ export default {
38
+ dev: {
39
+ server: {
40
+ headers: {
41
+ 'X-Custom-Foo': 'bar',
42
+ },
43
+ },
44
+ },
45
+ };
46
+ ```
47
+
48
+ For more details, please refer to the [Rsbuild - server.headers](https://v2.rsbuild.rs/config/server/headers) documentation.
49
+
50
+ ### historyApiFallback
51
+
52
+ - **Type:** `boolean | ConnectHistoryApiFallbackOptions`
53
+ - **Default:** `false`
54
+
55
+ The index.html page will likely have to be served in place of any 404 responses. Enable `dev.server.historyApiFallback` by setting it to `true`:
56
+
57
+ ```js
58
+ export default {
59
+ dev: {
60
+ server: {
61
+ historyApiFallback: true,
62
+ },
63
+ },
64
+ };
65
+ ```
66
+
67
+ For more configuration options, please refer to the [Rsbuild - server.historyApiFallback](https://v2.rsbuild.rs/config/server/history-api-fallback) documentation.
68
+
69
+ ### watch
70
+
71
+ - **Type:** `boolean`
72
+ - **Default:** `true`
73
+
74
+ Whether to watch files change in directories such as `mock/`, `server/`, `api/`.
75
+
76
+ For more details, please refer to the [Rsbuild - dev.watchFiles](https://v2.rsbuild.rs/config/dev/watch-files) documentation.
77
+
78
+ ### cors
79
+
80
+ - **Type:** `boolean | import('cors').CorsOptions`
81
+
82
+ Configure CORS (Cross-Origin Resource Sharing) for the development server.
83
+
84
+ The default configuration for `cors` in Modern.js follows Rsbuild's defaults:
85
+
86
+ ```ts
87
+ const defaultAllowedOrigins =
88
+ /^https?:\/\/(?:(?:[^:]+\.)?localhost|127\.0\.0\.1|\[::1\])(?::\d+)?$/;
89
+
90
+ const defaultOptions = {
91
+ // Default allowed:
92
+ // - localhost
93
+ // - 127.0.0.1
94
+ // - [::1]
95
+ origin: defaultAllowedOrigins,
96
+ };
97
+ ```
98
+
99
+ For more configuration options and detailed usage, please refer to the [Rsbuild - server.cors](https://v2.rsbuild.rs/config/server/cors) documentation.
100
+
101
+ ### proxy
102
+
103
+ - **Type:** `ProxyOptions[] | Record<string, string | ProxyOptions>`
104
+ - **Default:** `undefined`
105
+
106
+ Configure proxy rules for the dev server, and forward requests to the specified service.
107
+
108
+ ```js
109
+ export default {
110
+ dev: {
111
+ server: {
112
+ proxy: {
113
+ // http://localhost:8080/api -> https://example.com/api
114
+ // http://localhost:8080/api/foo -> https://example.com/api/foo
115
+ '/api': 'https://example.com',
116
+ },
117
+ },
118
+ },
119
+ };
120
+ ```
121
+
122
+ :::tip
123
+ This option is the same as Rsbuild's `server.proxy` option, see [Rsbuild - server.proxy](https://v2.rsbuild.rs/config/server/proxy) for detailed usage.
124
+ :::
@@ -0,0 +1,32 @@
1
+ # dev.setupMiddlewares
2
+
3
+ - **Type:**
4
+
5
+ ```ts
6
+ type RequestHandler = (req: any, res: any, next: () => void) => void;
7
+
8
+ type ExposeServerApis = {
9
+ sockWrite: (
10
+ type: string,
11
+ data?: string | boolean | Record<string, any>,
12
+ ) => void;
13
+ };
14
+
15
+ type SetupMiddlewares = Array<
16
+ (
17
+ middlewares: {
18
+ unshift: (...handlers: RequestHandler[]) => void;
19
+ push: (...handlers: RequestHandler[]) => void;
20
+ },
21
+ server: ExposeServerApis,
22
+ ) => void
23
+ >;
24
+ ```
25
+
26
+ - **Default:** `undefined`
27
+
28
+ Provides the ability to execute a custom function and apply custom middlewares.
29
+
30
+ :::info
31
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - dev.setupMiddlewares](https://v2.rsbuild.dev/config/dev/setup-middlewares).
32
+ :::
@@ -0,0 +1,48 @@
1
+ # dev.startUrl
2
+
3
+ - **Type:** `boolean | string | string[] | undefined`
4
+ - **Default:** `undefined`
5
+
6
+ `dev.startUrl` is used to set the URL of the page that automatically opens in the browser when Dev Server starts.
7
+
8
+ By default, no page will be opened.
9
+
10
+ You can set it to the following values:
11
+
12
+ ```js
13
+ export default {
14
+ dev: {
15
+ // Open the project's default preview page, equivalent to `http://localhost:<port>`
16
+ startUrl: true,
17
+ // Open the specified page
18
+ startUrl: 'http://localhost:8080',
19
+ // Open multiple pages
20
+ startUrl: ['http://localhost:8080', 'http://localhost:8080/about'],
21
+ },
22
+ };
23
+ ```
24
+
25
+ ### Port placeholder
26
+
27
+ Since the port number may change, you can use the `<port>` placeholder to refer to the current port number, and Modern.js will automatically replace the placeholder with the actual listening port number.
28
+
29
+ ```js
30
+ export default {
31
+ dev: {
32
+ startUrl: 'http://localhost:<port>/home',
33
+ },
34
+ };
35
+ ```
36
+
37
+ ### Open the specified browser
38
+
39
+ On MacOS, you can open the specified browser when Dev Server starts, by set environment variable `BROWSER`, support values:
40
+
41
+ - Google Chrome Canary
42
+ - Google Chrome Dev
43
+ - Google Chrome Beta
44
+ - Google Chrome
45
+ - Microsoft Edge
46
+ - Brave Browser
47
+ - Vivaldi
48
+ - Chromium
@@ -0,0 +1,27 @@
1
+ # dev.watchFiles
2
+
3
+ - **Type:**
4
+
5
+ ```ts
6
+ type WatchFiles =
7
+ | {
8
+ paths: string | string[];
9
+ type?: 'reload-page';
10
+ // watch options for chokidar
11
+ options?: WatchOptions;
12
+ }
13
+ | {
14
+ paths: string | string[];
15
+ type?: 'reload-server';
16
+ };
17
+
18
+ type WatchFilesConfig = WatchFiles | WatchFiles[];
19
+ ```
20
+
21
+ - **Default:** `undefined`
22
+
23
+ Watch specified files and directories for changes. When a file change is detected, it can trigger a page reload or restart the dev server.
24
+
25
+ :::info
26
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - dev.watchFiles](https://v2.rsbuild.dev/config/dev/watch-files).
27
+ :::
@@ -0,0 +1,10 @@
1
+ # dev.writeToDisk
2
+
3
+ - **Type:** `boolean | ((filename: string) => boolean)`
4
+ - **Default:** `(file) => !file.includes('.hot-update.')`
5
+
6
+ Controls whether the build output from development mode is written to disk.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - dev.writeToDisk](https://v2.rsbuild.dev/config/dev/write-to-disk).
10
+ :::
@@ -0,0 +1,31 @@
1
+ # sourceBuild
2
+
3
+ - **Type:** `boolean | PluginSourceBuildOptions`
4
+ - **Default:** `false`
5
+
6
+ Used to enable the ability for source code building. When this configuration option is enabled, Modern.js will read the source code files corresponding to the `source` field in the sub-project's package.json and compile them.
7
+
8
+ ```ts
9
+ export default {
10
+ experiments: {
11
+ sourceBuild: true,
12
+ },
13
+ };
14
+ ```
15
+
16
+ More detail can see ["Source Code Build Mode"](https://modernjs.dev/en/guides/advanced-features/source-build.html)。
17
+
18
+ ### Options
19
+
20
+ `experiments.sourceBuild` is implemented based on [@rsbuild/plugin-source-build](https://github.com/rstackjs/rsbuild-plugin-source-build?tab=readme-ov-file#options). You can pass plugin options like this:
21
+
22
+ ```ts
23
+ export default {
24
+ experiments: {
25
+ sourceBuild: {
26
+ sourceField: 'my-source',
27
+ resolvePriority: 'output',
28
+ },
29
+ },
30
+ };
31
+ ```
@@ -0,0 +1,28 @@
1
+ # html.appIcon
2
+
3
+ - **Type:**
4
+
5
+ ```ts
6
+ type AppIconItem = {
7
+ src: string;
8
+ size: number;
9
+ target?: 'apple-touch-icon' | 'web-app-manifest';
10
+ };
11
+
12
+ type AppIcon = {
13
+ name?: string;
14
+ icons: AppIconItem[];
15
+ filename?: string;
16
+ };
17
+ ```
18
+
19
+ - **Default:** `undefined`
20
+
21
+ Set the web application icons to display when added to the home screen of a mobile device:
22
+
23
+ - Generate the web app manifest file and its `icons` field.
24
+ - Generate the `apple-touch-icon` and `manifest` tags in the HTML file.
25
+
26
+ :::info
27
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.appIcon](https://v2.rsbuild.dev/config/html/app-icon).
28
+ :::
@@ -0,0 +1,10 @@
1
+ # html.crossorigin
2
+
3
+ - **Type:** `boolean | 'anonymous' | 'use-credentials'`
4
+ - **Default:** `false`
5
+
6
+ Set the [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) attribute of the `<script>` and `<style>` tags.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.crossorigin](https://v2.rsbuild.dev/config/html/crossorigin).
10
+ :::
@@ -0,0 +1,16 @@
1
+ # html.favicon
2
+
3
+ - **Type:** `string | Function`
4
+ - **Default:** `undefined`
5
+
6
+ Set the favicon icon path for all pages, can be set as:
7
+
8
+ - a URL.
9
+ - an absolute path to the file.
10
+ - a relative path relative to the project root directory.
11
+
12
+ After config this option, the favicon will be automatically copied to the dist directory during the compilation, and the corresponding `link` tag will be added to the HTML.
13
+
14
+ :::info
15
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.favicon](https://v2.rsbuild.dev/config/html/favicon).
16
+ :::
@@ -0,0 +1,10 @@
1
+ # html.inject
2
+
3
+ - **Type:** `'head' | 'body' | boolean | Function`
4
+ - **Default:** `'head'`
5
+
6
+ Set the inject position of the `<script>` tag.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.inject](https://v2.rsbuild.dev/config/html/inject).
10
+ :::
@@ -0,0 +1,24 @@
1
+ # html.meta
2
+
3
+ - **Type:** `Object | Function`
4
+ - **Default:**
5
+
6
+ ```js
7
+ const defaultMeta = {
8
+ charset: { charset: 'utf-8' },
9
+ viewport:
10
+ 'width=device-width, initial-scale=1.0, shrink-to-fit=no, viewport-fit=cover, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no',
11
+ 'http-equiv': { 'http-equiv': 'x-ua-compatible', content: 'ie=edge' },
12
+ renderer: 'webkit',
13
+ layoutmode: 'standard',
14
+ imagemode: 'force',
15
+ 'wap-font-scale': 'no',
16
+ 'format-detection': 'telephone=no',
17
+ };
18
+ ```
19
+
20
+ Configure the `<meta>` tag of the HTML.
21
+
22
+ :::info
23
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.meta](https://v2.rsbuild.dev/config/html/meta).
24
+ :::
@@ -0,0 +1,10 @@
1
+ # html.mountId
2
+
3
+ - **Type:** `string`
4
+ - **Default:** `'root'`
5
+
6
+ By default, the `root` element is included in the HTML template for component mounting, and the element id can be modified through `mountId`.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.mountId](https://v2.rsbuild.dev/config/html/mount-id).
10
+ :::
@@ -0,0 +1,10 @@
1
+ # html.outputStructure
2
+
3
+ - **Type:** `'flat' | 'nested'`
4
+ - **Default:** `'nested'`
5
+
6
+ Define the directory structure of the HTML output files.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.outputStructure](https://v2.rsbuild.dev/config/html/output-structure).
10
+ :::
@@ -0,0 +1,10 @@
1
+ # html.scriptLoading
2
+
3
+ - **Type:** `'defer' | 'blocking' | 'module'`
4
+ - **Default:** `'defer'`
5
+
6
+ Used to set how `<script>` tags are loaded.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.scriptLoading](https://v2.rsbuild.dev/config/html/script-loading).
10
+ :::
@@ -0,0 +1,15 @@
1
+ # html.tags
2
+
3
+ - **Type:**
4
+
5
+ ```ts
6
+ type TagsConfig = HtmlTag | HtmlTagHandler | Array<HtmlTag | HtmlTagHandler>;
7
+ ```
8
+
9
+ - **Default:** `undefined`
10
+
11
+ Modifies the tags that are injected into the HTML page.
12
+
13
+ :::info
14
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.tags](https://v2.rsbuild.dev/config/html/tags).
15
+ :::
@@ -0,0 +1,33 @@
1
+ # html.templateParameters
2
+
3
+ - **Type:** `Record<string, unknown> | Function`
4
+ - **Default:**
5
+
6
+ ```ts
7
+ type DefaultParameters = {
8
+ mountId: string; // the value of `html.mountId` config
9
+ entryName: string; // entry name
10
+ assetPrefix: string; // the value of dev.assetPrefix or output.assetPrefix configs
11
+ compilation: Compilation; // Compilation object of Rspack
12
+ rspackConfig: Rspack.Configuration; // Rspack config object
13
+ // generated by html-rspack-plugin
14
+ htmlPlugin: {
15
+ tags: {
16
+ headTags: HtmlTagObject[];
17
+ bodyTags: HtmlTagObject[];
18
+ };
19
+ files: {
20
+ publicPath: string;
21
+ js: Array<string>;
22
+ css: Array<string>;
23
+ favicon?: string;
24
+ };
25
+ };
26
+ };
27
+ ```
28
+
29
+ Define the parameters in the HTML template, corresponding to the `templateParameters` config of [html-rspack-plugin](https://github.com/rstackjs/html-rspack-plugin). You can use the config as an object or a function.
30
+
31
+ :::info
32
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.templateParameters](https://v2.rsbuild.dev/config/html/template-parameters).
33
+ :::
@@ -0,0 +1,10 @@
1
+ # html.template
2
+
3
+ - **Type:** `string | Function`
4
+ - **Default:**
5
+
6
+ Specifies the file path for the HTML template, which can be a relative or absolute path.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.template](https://v2.rsbuild.dev/config/html/template).
10
+ :::
@@ -0,0 +1,18 @@
1
+ # html.title
2
+
3
+ - **Type:** `string | Function`
4
+ - **Default:** `''`
5
+
6
+ Set the title tag of the HTML page, for example:
7
+
8
+ ```js
9
+ export default {
10
+ html: {
11
+ title: 'example',
12
+ },
13
+ };
14
+ ```
15
+
16
+ :::info
17
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - html.title](https://v2.rsbuild.dev/config/html/title).
18
+ :::
@@ -0,0 +1,11 @@
1
+ # output.assetPrefix
2
+
3
+ - **Type:** `string | 'auto'`
4
+ - **Default:** `'/'`
5
+
6
+ In production mode, use this option to set the URL prefix for static assets, such as setting it to a CDN URL.
7
+
8
+
9
+ :::info
10
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - output.assetPrefix](https://v2.rsbuild.dev/config/output/asset-prefix).
11
+ :::
@@ -0,0 +1,77 @@
1
+ # output.assetsRetry
2
+
3
+ - **Type:** `Object`
4
+
5
+ `output.assetsRetry` is used to configure the retry of assets.The type of `AssetsRetryOptions` is as follows:
6
+
7
+ ```ts
8
+ export type AssetsRetryHookContext = {
9
+ times: number;
10
+ domain: string;
11
+ url: string;
12
+ tagName: string;
13
+ };
14
+
15
+ export type AssetsRetryOptions = {
16
+ type?: string[];
17
+ domain?: string[];
18
+ max?: number;
19
+ test?: string | ((url: string) => boolean);
20
+ crossOrigin?: boolean | 'anonymous' | 'use-credentials';
21
+ inlineScript?: boolean;
22
+ onRetry?: (options: AssetsRetryHookContext) => void;
23
+ onSuccess?: (options: AssetsRetryHookContext) => void;
24
+ onFail?: (options: AssetsRetryHookContext) => void;
25
+ };
26
+ ```
27
+
28
+ - **Default:** `undefined`
29
+
30
+ - Since this feature injects some runtime code into your HTML and [Rspack Runtime](https://rspack.rs/api/runtime-api/module-variables), it is disabled by default. To enable it, provide an object for the option, for example:
31
+
32
+ ```js
33
+ export default {
34
+ output: {
35
+ assetsRetry: {},
36
+ },
37
+ };
38
+ ```
39
+
40
+ When you enable this feature, the default configuration for `assetsRetry` is:
41
+
42
+ ```ts
43
+ export const defaultAssetsRetryOptions: AssetsRetryOptions = {
44
+ type: ['script', 'link', 'img'],
45
+ domain: [],
46
+ max: 3,
47
+ test: '',
48
+ crossOrigin: false,
49
+ inlineScript: false,
50
+ onRetry: () => {},
51
+ onSuccess: () => {},
52
+ onFail: () => {},
53
+ };
54
+ ```
55
+
56
+ ### Example
57
+
58
+ You can also customize your retry logic using the `assetsRetry` options.
59
+
60
+ For example, setting `assetsRetry.domain` to specify the retry domain when assets fail to load.
61
+
62
+ As an example, you can specify a list of fallback domains via `assetsRetry.domain`. The first domain in the list should match the domain used in your [`assetsPrefix`](/configure/app/output/asset-prefix.md) configuration:
63
+
64
+ ```js
65
+ export default {
66
+ output: {
67
+ assetsRetry: {
68
+ domain: ['cdn1.com', 'cdn2.com', 'cdn3.com'],
69
+ },
70
+ assetsPrefix: 'https://cdn1.com', // or '//cdn1.com'
71
+ },
72
+ };
73
+ ```
74
+
75
+ With the configuration above, if an asset fails to load from `cdn1.com`, requests will automatically fall back to `cdn2.com`. If `cdn2.com` also fails, the request will continue to `cdn3.com`.
76
+
77
+ `assetsRetry` is implemented based on the Assets Retry plugin of Rsbuild and provides the same configuration options. You can refer to [Rsbuild - Assets Retry Plugin](https://github.com/rstackjs/rsbuild-plugin-assets-retry) to understand all available configuration options.
@@ -0,0 +1,10 @@
1
+ # output.charset
2
+
3
+ - **Type:** `'ascii' | 'utf8'`
4
+ - **Default:** `'ascii'`
5
+
6
+ The `charset` config allows you to specify the [character encoding](https://developer.mozilla.org/en-US/docs/Glossary/Character_encoding) for output files to ensure they are displayed correctly in different environments.
7
+
8
+ :::info
9
+ The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - output.charset](https://v2.rsbuild.dev/config/output/charset).
10
+ :::
@@ -0,0 +1,16 @@
1
+ # output.cleanDistPath
2
+
3
+ - **Type:** `boolean`
4
+ - **Default:** `true`
5
+
6
+ Whether to clean all files in the dist path before starting compilation.
7
+
8
+ By default, Modern.js will automatically clean up the files in the dist directory, you can disable this behavior by setting `cleanDistPath` to `false`.
9
+
10
+ ```js
11
+ export default {
12
+ output: {
13
+ cleanDistPath: false,
14
+ },
15
+ };
16
+ ```