@modern-js/main-doc 0.0.0-next-20221116121040

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 (531) hide show
  1. package/.eslintrc.js +12 -0
  2. package/CHANGELOG.md +15 -0
  3. package/LICENSE +144 -0
  4. package/en/configure/app/dev/asset-prefix.md +13 -0
  5. package/en/configure/app/dev/hmr.md +13 -0
  6. package/en/configure/app/dev/https.md +13 -0
  7. package/en/configure/app/dev/port.md +13 -0
  8. package/en/configure/app/dev/progress-bar.md +13 -0
  9. package/en/configure/app/dev/start-url.md +13 -0
  10. package/en/configure/app/html/app-icon.md +13 -0
  11. package/en/configure/app/html/crossorigin.md +13 -0
  12. package/en/configure/app/html/disable-html-folder.md +13 -0
  13. package/en/configure/app/html/favicon-by-entries.md +13 -0
  14. package/en/configure/app/html/favicon.md +13 -0
  15. package/en/configure/app/html/inject-by-entries.md +13 -0
  16. package/en/configure/app/html/inject.md +13 -0
  17. package/en/configure/app/html/meta-by-entries.md +13 -0
  18. package/en/configure/app/html/meta.md +13 -0
  19. package/en/configure/app/html/mount-id.md +13 -0
  20. package/en/configure/app/html/template-by-entries.md +13 -0
  21. package/en/configure/app/html/template-parameters-by-entries.md +13 -0
  22. package/en/configure/app/html/template-parameters.md +13 -0
  23. package/en/configure/app/html/template.md +13 -0
  24. package/en/configure/app/html/title-by-entries.md +13 -0
  25. package/en/configure/app/html/title.md +13 -0
  26. package/en/configure/app/output/asset-prefix.md +13 -0
  27. package/en/configure/app/output/assets-retry.md +13 -0
  28. package/en/configure/app/output/charset.md +13 -0
  29. package/en/configure/app/output/clean-dist-path.md +13 -0
  30. package/en/configure/app/output/convert-to-rem.md +13 -0
  31. package/en/configure/app/output/copy.md +13 -0
  32. package/en/configure/app/output/css-module-local-ident-name.md +13 -0
  33. package/en/configure/app/output/data-uri-limit.md +13 -0
  34. package/en/configure/app/output/disable-css-module-extension.md +13 -0
  35. package/en/configure/app/output/disable-filename-hash.md +13 -0
  36. package/en/configure/app/output/disable-inline-runtime-chunk.md +13 -0
  37. package/en/configure/app/output/disable-minimize.md +13 -0
  38. package/en/configure/app/output/disable-source-map.md +13 -0
  39. package/en/configure/app/output/dist-path.md +13 -0
  40. package/en/configure/app/output/enable-asset-fallback.md +13 -0
  41. package/en/configure/app/output/enable-asset-manifest.md +13 -0
  42. package/en/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
  43. package/en/configure/app/output/enable-inline-scripts.md +13 -0
  44. package/en/configure/app/output/enable-inline-styles.md +13 -0
  45. package/en/configure/app/output/enable-latest-decorators.md +13 -0
  46. package/en/configure/app/output/externals.md +13 -0
  47. package/en/configure/app/output/filename.md +13 -0
  48. package/en/configure/app/output/legal-comments.md +13 -0
  49. package/en/configure/app/output/override-browserslist.md +13 -0
  50. package/en/configure/app/output/polyfill.md +13 -0
  51. package/en/configure/app/output/svg-default-export.md +13 -0
  52. package/en/configure/app/performance/build-cache.md +13 -0
  53. package/en/configure/app/performance/bundle-analyze.md +13 -0
  54. package/en/configure/app/performance/chunk-split.md +13 -0
  55. package/en/configure/app/performance/print-file-size.md +13 -0
  56. package/en/configure/app/performance/profile.md +13 -0
  57. package/en/configure/app/performance/remove-console.md +13 -0
  58. package/en/configure/app/performance/remove-moment-locale.md +13 -0
  59. package/en/configure/app/security/sri.md +13 -0
  60. package/en/configure/app/source/alias.md +13 -0
  61. package/en/configure/app/source/compile-js-data-uri.md +13 -0
  62. package/en/configure/app/source/define.md +13 -0
  63. package/en/configure/app/source/global-vars.md +13 -0
  64. package/en/configure/app/source/include.md +13 -0
  65. package/en/configure/app/source/module-scopes.md +13 -0
  66. package/en/configure/app/source/pre-entry.md +13 -0
  67. package/en/configure/app/source/resolve-extension-prefix.md +13 -0
  68. package/en/configure/app/source/resolve-main-fields.md +13 -0
  69. package/en/configure/app/tools/autoprefixer.md +13 -0
  70. package/en/configure/app/tools/babel.md +13 -0
  71. package/en/configure/app/tools/css-extract.md +13 -0
  72. package/en/configure/app/tools/css-loader.md +13 -0
  73. package/en/configure/app/tools/dev-server.md +13 -0
  74. package/en/configure/app/tools/html-plugin.md +13 -0
  75. package/en/configure/app/tools/inspector.md +13 -0
  76. package/en/configure/app/tools/less.md +13 -0
  77. package/en/configure/app/tools/minify-css.md +13 -0
  78. package/en/configure/app/tools/postcss.md +13 -0
  79. package/en/configure/app/tools/pug.md +13 -0
  80. package/en/configure/app/tools/sass.md +13 -0
  81. package/en/configure/app/tools/style-loader.md +13 -0
  82. package/en/configure/app/tools/styled-components.md +13 -0
  83. package/en/configure/app/tools/terser.md +13 -0
  84. package/en/configure/app/tools/ts-checker.md +13 -0
  85. package/en/configure/app/tools/ts-loader.md +13 -0
  86. package/en/configure/app/tools/webpack-chain.md +13 -0
  87. package/en/configure/app/tools/webpack.md +13 -0
  88. package/en/tutorials/foundations/_category_.json +5 -0
  89. package/en/tutorials/foundations/basic.md +8 -0
  90. package/en/tutorials/foundations/introduction.md +43 -0
  91. package/package.json +30 -0
  92. package/scripts/gen-config.ts +60 -0
  93. package/scripts/sync.ts +36 -0
  94. package/tsconfig.json +7 -0
  95. package/zh/apis/app/commands/_category_.json +8 -0
  96. package/zh/apis/app/commands/build.md +44 -0
  97. package/zh/apis/app/commands/dev.md +31 -0
  98. package/zh/apis/app/commands/index.md +12 -0
  99. package/zh/apis/app/commands/inspect.md +39 -0
  100. package/zh/apis/app/commands/lint.md +22 -0
  101. package/zh/apis/app/commands/new.md +59 -0
  102. package/zh/apis/app/commands/start.md +32 -0
  103. package/zh/apis/app/commands/test.md +36 -0
  104. package/zh/apis/app/commands/upgrade.md +23 -0
  105. package/zh/apis/app/hooks/_category_.json +8 -0
  106. package/zh/apis/app/hooks/api/_category_.json +4 -0
  107. package/zh/apis/app/hooks/api/framework/_category_.json +4 -0
  108. package/zh/apis/app/hooks/api/framework/app.md +100 -0
  109. package/zh/apis/app/hooks/api/framework/lambda.md +79 -0
  110. package/zh/apis/app/hooks/api/functions/_category_.json +4 -0
  111. package/zh/apis/app/hooks/api/functions/api.md +50 -0
  112. package/zh/apis/app/hooks/api/functions/app.md +10 -0
  113. package/zh/apis/app/hooks/api/functions/common.md +10 -0
  114. package/zh/apis/app/hooks/api/test.md +12 -0
  115. package/zh/apis/app/hooks/config/_category_.json +4 -0
  116. package/zh/apis/app/hooks/config/html.md +10 -0
  117. package/zh/apis/app/hooks/config/icon.md +17 -0
  118. package/zh/apis/app/hooks/config/mock.md +12 -0
  119. package/zh/apis/app/hooks/config/public.md +30 -0
  120. package/zh/apis/app/hooks/config/storybook.md +14 -0
  121. package/zh/apis/app/hooks/config/upload.md +48 -0
  122. package/zh/apis/app/hooks/index.md +12 -0
  123. package/zh/apis/app/hooks/modern-config.md +10 -0
  124. package/zh/apis/app/hooks/server/_category_.json +4 -0
  125. package/zh/apis/app/hooks/server/index.md +14 -0
  126. package/zh/apis/app/hooks/server/test.md +12 -0
  127. package/zh/apis/app/hooks/shared.md +8 -0
  128. package/zh/apis/app/hooks/src/_category_.json +4 -0
  129. package/zh/apis/app/hooks/src/app.md +41 -0
  130. package/zh/apis/app/hooks/src/error.md +10 -0
  131. package/zh/apis/app/hooks/src/eslint.md +9 -0
  132. package/zh/apis/app/hooks/src/index.md +35 -0
  133. package/zh/apis/app/hooks/src/pages.md +183 -0
  134. package/zh/apis/app/hooks/src/stories.md +14 -0
  135. package/zh/apis/app/hooks/src/test.md +12 -0
  136. package/zh/apis/app/overview.md +11 -0
  137. package/zh/apis/app/runtime/_category_.json +9 -0
  138. package/zh/apis/app/runtime/app/_category_.json +4 -0
  139. package/zh/apis/app/runtime/app/bootstrap.md +83 -0
  140. package/zh/apis/app/runtime/app/create-app.md +47 -0
  141. package/zh/apis/app/runtime/app/define-config.md +57 -0
  142. package/zh/apis/app/runtime/app/head.md +43 -0
  143. package/zh/apis/app/runtime/app/no-ssr.md +41 -0
  144. package/zh/apis/app/runtime/app/pre-render.md +77 -0
  145. package/zh/apis/app/runtime/app/use-module-app.md +60 -0
  146. package/zh/apis/app/runtime/app/use-module-apps.md +64 -0
  147. package/zh/apis/app/runtime/app/use-runtime-context.md +39 -0
  148. package/zh/apis/app/runtime/bff-server/_category_.json +4 -0
  149. package/zh/apis/app/runtime/bff-server/after-lambda-registed.md +35 -0
  150. package/zh/apis/app/runtime/bff-server/hook.md +120 -0
  151. package/zh/apis/app/runtime/bff-server/use-context.md +70 -0
  152. package/zh/apis/app/runtime/container/_category_.json +4 -0
  153. package/zh/apis/app/runtime/container/router.md +492 -0
  154. package/zh/apis/app/runtime/container/use-loader.md +64 -0
  155. package/zh/apis/app/runtime/default-alias.md +26 -0
  156. package/zh/apis/app/runtime/env.md +68 -0
  157. package/zh/apis/app/runtime/index.md +12 -0
  158. package/zh/apis/app/runtime/model/Provider.md +36 -0
  159. package/zh/apis/app/runtime/model/_category_.json +4 -0
  160. package/zh/apis/app/runtime/model/auto-actions.md +121 -0
  161. package/zh/apis/app/runtime/model/connect.md +134 -0
  162. package/zh/apis/app/runtime/model/create-app.md +74 -0
  163. package/zh/apis/app/runtime/model/create-store.md +60 -0
  164. package/zh/apis/app/runtime/model/handle-effect.md +106 -0
  165. package/zh/apis/app/runtime/model/model_.md +199 -0
  166. package/zh/apis/app/runtime/model/use-local-model.md +28 -0
  167. package/zh/apis/app/runtime/model/use-model.md +87 -0
  168. package/zh/apis/app/runtime/model/use-static-model.md +47 -0
  169. package/zh/apis/app/runtime/model/use-store.md +48 -0
  170. package/zh/apis/app/runtime/plugin/_category_.json +4 -0
  171. package/zh/apis/app/runtime/plugin/abstract.md +26 -0
  172. package/zh/apis/app/runtime/plugin/hook-api.md +896 -0
  173. package/zh/apis/app/runtime/plugin/hook.md +170 -0
  174. package/zh/apis/app/runtime/plugin/plugin-api.md +117 -0
  175. package/zh/apis/app/runtime/testing/_category_.json +4 -0
  176. package/zh/apis/app/runtime/testing/act.md +34 -0
  177. package/zh/apis/app/runtime/testing/cleanup.md +37 -0
  178. package/zh/apis/app/runtime/testing/render.md +52 -0
  179. package/zh/apis/app/runtime/testing/renderApp.md +31 -0
  180. package/zh/apis/app/runtime/utility/_category_.json +4 -0
  181. package/zh/apis/app/runtime/utility/css-in-js.md +60 -0
  182. package/zh/apis/app/runtime/utility/loadable/_category_.json +4 -0
  183. package/zh/apis/app/runtime/utility/loadable/lazy.md +29 -0
  184. package/zh/apis/app/runtime/utility/loadable/loadable-component.md +61 -0
  185. package/zh/apis/app/runtime/utility/loadable/loadable-library.md +67 -0
  186. package/zh/apis/app/runtime/utility/loadable/loadable_.md +110 -0
  187. package/zh/apis/app/runtime/web-server/_category_.json +4 -0
  188. package/zh/apis/app/runtime/web-server/hook.md +121 -0
  189. package/zh/apis/generator/overview.md +32 -0
  190. package/zh/apis/generator/plugin/_category_.json +4 -0
  191. package/zh/apis/generator/plugin/file/_category_.json +4 -0
  192. package/zh/apis/generator/plugin/file/addFile.md +52 -0
  193. package/zh/apis/generator/plugin/file/addHelper.md +26 -0
  194. package/zh/apis/generator/plugin/file/addManyFile.md +55 -0
  195. package/zh/apis/generator/plugin/file/addPartial.md +26 -0
  196. package/zh/apis/generator/plugin/file/introduce.md +37 -0
  197. package/zh/apis/generator/plugin/file/rmDir.md +24 -0
  198. package/zh/apis/generator/plugin/file/rmFile.md +24 -0
  199. package/zh/apis/generator/plugin/file/updateJSONFile.md +52 -0
  200. package/zh/apis/generator/plugin/file/updateModernConfig.md +26 -0
  201. package/zh/apis/generator/plugin/file/updateTextRawFile.md +33 -0
  202. package/zh/apis/generator/plugin/git/_category_.json +4 -0
  203. package/zh/apis/generator/plugin/git/gitAddAndCommit.md +20 -0
  204. package/zh/apis/generator/plugin/git/initGitRepo.md +16 -0
  205. package/zh/apis/generator/plugin/git/isInGitRepo.md +16 -0
  206. package/zh/apis/generator/plugin/hook/_category_.json +4 -0
  207. package/zh/apis/generator/plugin/hook/afterForged.md +35 -0
  208. package/zh/apis/generator/plugin/hook/onForged.md +35 -0
  209. package/zh/apis/generator/plugin/info/_category_.json +4 -0
  210. package/zh/apis/generator/plugin/info/isFileExit.md +22 -0
  211. package/zh/apis/generator/plugin/info/locale.md +17 -0
  212. package/zh/apis/generator/plugin/info/readDir.md +22 -0
  213. package/zh/apis/generator/plugin/input/_category_.json +4 -0
  214. package/zh/apis/generator/plugin/input/addInputAfter.md +48 -0
  215. package/zh/apis/generator/plugin/input/addInputBefore.md +48 -0
  216. package/zh/apis/generator/plugin/input/addOptionAfter.md +45 -0
  217. package/zh/apis/generator/plugin/input/addOptionBefore.md +45 -0
  218. package/zh/apis/generator/plugin/input/setInput.md +42 -0
  219. package/zh/apis/generator/plugin/input/setInputValue.md +28 -0
  220. package/zh/apis/generator/plugin/input/type.md +101 -0
  221. package/zh/apis/generator/plugin/introduce.md +93 -0
  222. package/zh/apis/generator/plugin/new/_category_.json +4 -0
  223. package/zh/apis/generator/plugin/new/createElement.md +33 -0
  224. package/zh/apis/generator/plugin/new/createSubProject.md +35 -0
  225. package/zh/apis/generator/plugin/new/enableFunc.md +46 -0
  226. package/zh/apis/generator/plugin/new/introduce.md +15 -0
  227. package/zh/apis/generator/plugin/npm/_category_.json +4 -0
  228. package/zh/apis/generator/plugin/npm/install.md +16 -0
  229. package/zh/apis/monorepo/commands/_category_.json +8 -0
  230. package/zh/apis/monorepo/commands/bump.md +42 -0
  231. package/zh/apis/monorepo/commands/change.md +58 -0
  232. package/zh/apis/monorepo/commands/clear.md +27 -0
  233. package/zh/apis/monorepo/commands/deploy.md +39 -0
  234. package/zh/apis/monorepo/commands/gen-release-note.md +35 -0
  235. package/zh/apis/monorepo/commands/index.md +12 -0
  236. package/zh/apis/monorepo/commands/lint.md +21 -0
  237. package/zh/apis/monorepo/commands/new.md +41 -0
  238. package/zh/apis/monorepo/commands/pre.md +68 -0
  239. package/zh/apis/monorepo/commands/release.md +20 -0
  240. package/zh/apis/monorepo/commands/upgrade.md +23 -0
  241. package/zh/apis/monorepo/hooks/_category_.json +8 -0
  242. package/zh/apis/monorepo/hooks/apps.md +12 -0
  243. package/zh/apis/monorepo/hooks/code-workspace.md +10 -0
  244. package/zh/apis/monorepo/hooks/examples.md +14 -0
  245. package/zh/apis/monorepo/hooks/features.md +14 -0
  246. package/zh/apis/monorepo/hooks/index.md +12 -0
  247. package/zh/apis/monorepo/hooks/packages.md +14 -0
  248. package/zh/apis/monorepo/hooks/pnpm-workspace.md +10 -0
  249. package/zh/apis/monorepo/hooks/pnpmfile.md +10 -0
  250. package/zh/apis/monorepo/overview.md +11 -0
  251. package/zh/community/index.md +3 -0
  252. package/zh/components/command-tip.md +57 -0
  253. package/zh/components/deploy.md +60 -0
  254. package/zh/components/dev-ide.md +1 -0
  255. package/zh/components/entry-name.md +15 -0
  256. package/zh/components/env-prepare.md +1 -0
  257. package/zh/components/launch-bff-choices.md +6 -0
  258. package/zh/components/reduck-tip.md +5 -0
  259. package/zh/configure/app/bff/_category_.json +4 -0
  260. package/zh/configure/app/bff/fetcher.md +32 -0
  261. package/zh/configure/app/bff/prefix.md +38 -0
  262. package/zh/configure/app/bff/proxy.md +76 -0
  263. package/zh/configure/app/dev/_category_.json +4 -0
  264. package/zh/configure/app/dev/asset-prefix.md +13 -0
  265. package/zh/configure/app/dev/hmr.md +13 -0
  266. package/zh/configure/app/dev/https.md +13 -0
  267. package/zh/configure/app/dev/port.md +13 -0
  268. package/zh/configure/app/dev/progress-bar.md +13 -0
  269. package/zh/configure/app/dev/proxy.md +79 -0
  270. package/zh/configure/app/dev/start-url.md +13 -0
  271. package/zh/configure/app/dev/with-master-app.md +35 -0
  272. package/zh/configure/app/html/app-icon.md +13 -0
  273. package/zh/configure/app/html/crossorigin.md +13 -0
  274. package/zh/configure/app/html/disable-html-folder.md +13 -0
  275. package/zh/configure/app/html/favicon-by-entries.md +13 -0
  276. package/zh/configure/app/html/favicon.md +13 -0
  277. package/zh/configure/app/html/inject-by-entries.md +13 -0
  278. package/zh/configure/app/html/inject.md +13 -0
  279. package/zh/configure/app/html/meta-by-entries.md +13 -0
  280. package/zh/configure/app/html/meta.md +13 -0
  281. package/zh/configure/app/html/mount-id.md +13 -0
  282. package/zh/configure/app/html/template-by-entries.md +13 -0
  283. package/zh/configure/app/html/template-parameters-by-entries.md +13 -0
  284. package/zh/configure/app/html/template-parameters.md +13 -0
  285. package/zh/configure/app/html/template.md +13 -0
  286. package/zh/configure/app/html/title-by-entries.md +13 -0
  287. package/zh/configure/app/html/title.md +13 -0
  288. package/zh/configure/app/output/_category_.json +4 -0
  289. package/zh/configure/app/output/asset-prefix.md +13 -0
  290. package/zh/configure/app/output/assets-retry.md +13 -0
  291. package/zh/configure/app/output/charset.md +13 -0
  292. package/zh/configure/app/output/clean-dist-path.md +13 -0
  293. package/zh/configure/app/output/convert-to-rem.md +13 -0
  294. package/zh/configure/app/output/copy.md +13 -0
  295. package/zh/configure/app/output/css-module-local-ident-name.md +13 -0
  296. package/zh/configure/app/output/data-uri-limit.md +13 -0
  297. package/zh/configure/app/output/disable-css-module-extension.md +13 -0
  298. package/zh/configure/app/output/disable-filename-hash.md +13 -0
  299. package/zh/configure/app/output/disable-inline-runtime-chunk.md +13 -0
  300. package/zh/configure/app/output/disable-minimize.md +13 -0
  301. package/zh/configure/app/output/disable-node-polyfill.md +24 -0
  302. package/zh/configure/app/output/disable-source-map.md +13 -0
  303. package/zh/configure/app/output/dist-path.md +13 -0
  304. package/zh/configure/app/output/enable-asset-fallback.md +13 -0
  305. package/zh/configure/app/output/enable-asset-manifest.md +13 -0
  306. package/zh/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
  307. package/zh/configure/app/output/enable-inline-scripts.md +13 -0
  308. package/zh/configure/app/output/enable-inline-styles.md +13 -0
  309. package/zh/configure/app/output/enable-latest-decorators.md +13 -0
  310. package/zh/configure/app/output/enable-modern-mode.md +26 -0
  311. package/zh/configure/app/output/externals.md +13 -0
  312. package/zh/configure/app/output/filename.md +13 -0
  313. package/zh/configure/app/output/legal-comments.md +13 -0
  314. package/zh/configure/app/output/override-browserslist.md +13 -0
  315. package/zh/configure/app/output/polyfill.md +13 -0
  316. package/zh/configure/app/output/ssg.md +226 -0
  317. package/zh/configure/app/output/svg-default-export.md +13 -0
  318. package/zh/configure/app/performance/build-cache.md +13 -0
  319. package/zh/configure/app/performance/bundle-analyze.md +13 -0
  320. package/zh/configure/app/performance/chunk-split.md +13 -0
  321. package/zh/configure/app/performance/print-file-size.md +13 -0
  322. package/zh/configure/app/performance/profile.md +13 -0
  323. package/zh/configure/app/performance/remove-console.md +13 -0
  324. package/zh/configure/app/performance/remove-moment-locale.md +13 -0
  325. package/zh/configure/app/plugins.md +74 -0
  326. package/zh/configure/app/runtime/_category_.json +4 -0
  327. package/zh/configure/app/runtime/master-app.md +72 -0
  328. package/zh/configure/app/runtime/router.md +54 -0
  329. package/zh/configure/app/runtime/state.md +45 -0
  330. package/zh/configure/app/security/sri.md +13 -0
  331. package/zh/configure/app/server/_category_.json +4 -0
  332. package/zh/configure/app/server/base-url.md +36 -0
  333. package/zh/configure/app/server/port.md +21 -0
  334. package/zh/configure/app/server/public-routes.md +29 -0
  335. package/zh/configure/app/server/routes.md +92 -0
  336. package/zh/configure/app/server/ssr-by-entries.md +32 -0
  337. package/zh/configure/app/server/ssr.md +24 -0
  338. package/zh/configure/app/source/_category_.json +4 -0
  339. package/zh/configure/app/source/alias.md +13 -0
  340. package/zh/configure/app/source/compile-js-data-uri.md +13 -0
  341. package/zh/configure/app/source/config-dir.md +15 -0
  342. package/zh/configure/app/source/define.md +13 -0
  343. package/zh/configure/app/source/design-system.md +1156 -0
  344. package/zh/configure/app/source/disable-default-entries.md +23 -0
  345. package/zh/configure/app/source/enable-async-entry.md +53 -0
  346. package/zh/configure/app/source/entries-dir.md +42 -0
  347. package/zh/configure/app/source/entries.md +55 -0
  348. package/zh/configure/app/source/global-vars.md +13 -0
  349. package/zh/configure/app/source/include.md +13 -0
  350. package/zh/configure/app/source/module-scopes.md +13 -0
  351. package/zh/configure/app/source/pre-entry.md +13 -0
  352. package/zh/configure/app/source/resolve-extension-prefix.md +13 -0
  353. package/zh/configure/app/source/resolve-main-fields.md +13 -0
  354. package/zh/configure/app/testing/_category_.json +4 -0
  355. package/zh/configure/app/testing/transformer.md +17 -0
  356. package/zh/configure/app/tools/_category_.json +4 -0
  357. package/zh/configure/app/tools/autoprefixer.md +13 -0
  358. package/zh/configure/app/tools/babel.md +13 -0
  359. package/zh/configure/app/tools/css-extract.md +13 -0
  360. package/zh/configure/app/tools/css-loader.md +13 -0
  361. package/zh/configure/app/tools/dev-server.md +13 -0
  362. package/zh/configure/app/tools/esbuild.md +61 -0
  363. package/zh/configure/app/tools/html-plugin.md +13 -0
  364. package/zh/configure/app/tools/inspector.md +13 -0
  365. package/zh/configure/app/tools/jest.md +41 -0
  366. package/zh/configure/app/tools/less.md +13 -0
  367. package/zh/configure/app/tools/minify-css.md +13 -0
  368. package/zh/configure/app/tools/postcss.md +13 -0
  369. package/zh/configure/app/tools/pug.md +13 -0
  370. package/zh/configure/app/tools/sass.md +13 -0
  371. package/zh/configure/app/tools/style-loader.md +13 -0
  372. package/zh/configure/app/tools/styled-components.md +13 -0
  373. package/zh/configure/app/tools/tailwindcss.md +48 -0
  374. package/zh/configure/app/tools/terser.md +13 -0
  375. package/zh/configure/app/tools/ts-checker.md +13 -0
  376. package/zh/configure/app/tools/ts-loader.md +13 -0
  377. package/zh/configure/app/tools/webpack-chain.md +13 -0
  378. package/zh/configure/app/tools/webpack.md +13 -0
  379. package/zh/configure/app/usage.md +81 -0
  380. package/zh/configure/generator/introduce.md +113 -0
  381. package/zh/configure/generator/module.md +43 -0
  382. package/zh/configure/generator/monorepo.md +28 -0
  383. package/zh/configure/generator/mwa.md +127 -0
  384. package/zh/guides/advanced-features/_category_.json +9 -0
  385. package/zh/guides/advanced-features/bff/_category_.json +4 -0
  386. package/zh/guides/advanced-features/bff/bff-proxy.md +25 -0
  387. package/zh/guides/advanced-features/bff/bff-server.md +142 -0
  388. package/zh/guides/advanced-features/bff/frameworks.md +348 -0
  389. package/zh/guides/advanced-features/bff/function.md +236 -0
  390. package/zh/guides/advanced-features/code-split.md +68 -0
  391. package/zh/guides/advanced-features/compatibility.md +89 -0
  392. package/zh/guides/advanced-features/custom-app.md +4 -0
  393. package/zh/guides/advanced-features/eslint.md +146 -0
  394. package/zh/guides/advanced-features/index.md +12 -0
  395. package/zh/guides/advanced-features/low-level.md +44 -0
  396. package/zh/guides/advanced-features/ssg.md +151 -0
  397. package/zh/guides/advanced-features/ssr.md +186 -0
  398. package/zh/guides/advanced-features/testing.md +4 -0
  399. package/zh/guides/advanced-features/typescript.md +4 -0
  400. package/zh/guides/advanced-features/web-server.md +135 -0
  401. package/zh/guides/basic-features/_category_.json +9 -0
  402. package/zh/guides/basic-features/alias.md +67 -0
  403. package/zh/guides/basic-features/css/_category_.json +4 -0
  404. package/zh/guides/basic-features/css/css-in-js.md +38 -0
  405. package/zh/guides/basic-features/css/css-modules.md +86 -0
  406. package/zh/guides/basic-features/css/less-sass.md +29 -0
  407. package/zh/guides/basic-features/css/postcss.md +81 -0
  408. package/zh/guides/basic-features/css/tailwindcss.md +98 -0
  409. package/zh/guides/basic-features/data-fetch.md +4 -0
  410. package/zh/guides/basic-features/env-vars.md +83 -0
  411. package/zh/guides/basic-features/html.md +128 -0
  412. package/zh/guides/basic-features/image.md +43 -0
  413. package/zh/guides/basic-features/index.md +12 -0
  414. package/zh/guides/basic-features/mock.md +85 -0
  415. package/zh/guides/basic-features/proxy.md +85 -0
  416. package/zh/guides/basic-features/routes.md +4 -0
  417. package/zh/guides/concept/_category_.json +5 -0
  418. package/zh/guides/concept/entries.md +4 -0
  419. package/zh/guides/concept/integrated.md +4 -0
  420. package/zh/guides/concept/lifecycle.md +4 -0
  421. package/zh/guides/concept/solutions.md +4 -0
  422. package/zh/guides/get-started/_category_.json +5 -0
  423. package/zh/guides/get-started/quick-start.md +4 -0
  424. package/zh/guides/get-started/upgrade.md +4 -0
  425. package/zh/guides/overview.md +11 -0
  426. package/zh/guides/topic-detail/_category_.json +5 -0
  427. package/zh/guides/topic-detail/changesets/_category_.json +4 -0
  428. package/zh/guides/topic-detail/changesets/add.md +125 -0
  429. package/zh/guides/topic-detail/changesets/changelog.md +239 -0
  430. package/zh/guides/topic-detail/changesets/commit.md +272 -0
  431. package/zh/guides/topic-detail/changesets/config.md +146 -0
  432. package/zh/guides/topic-detail/changesets/github.md +168 -0
  433. package/zh/guides/topic-detail/changesets/introduce.md +57 -0
  434. package/zh/guides/topic-detail/changesets/release-note.md +262 -0
  435. package/zh/guides/topic-detail/changesets/release-pre.md +49 -0
  436. package/zh/guides/topic-detail/changesets/release.md +228 -0
  437. package/zh/guides/topic-detail/compile-speed.md +182 -0
  438. package/zh/guides/topic-detail/framework-plugin/_category_.json +4 -0
  439. package/zh/guides/topic-detail/framework-plugin/abstract.md +27 -0
  440. package/zh/guides/topic-detail/framework-plugin/extend.md +163 -0
  441. package/zh/guides/topic-detail/framework-plugin/implement.md +188 -0
  442. package/zh/guides/topic-detail/framework-plugin/relationship.md +119 -0
  443. package/zh/guides/topic-detail/generator-plugin/_category_.json +4 -0
  444. package/zh/guides/topic-detail/generator-plugin/abstract.md +23 -0
  445. package/zh/guides/topic-detail/generator-plugin/develop.md +120 -0
  446. package/zh/guides/topic-detail/generator-plugin/use.md +61 -0
  447. package/zh/guides/topic-detail/micro-frontend/_category_.json +4 -0
  448. package/zh/guides/topic-detail/micro-frontend/communicate.md +39 -0
  449. package/zh/guides/topic-detail/micro-frontend/debugging.md +168 -0
  450. package/zh/guides/topic-detail/micro-frontend/introduction.md +13 -0
  451. package/zh/guides/topic-detail/micro-frontend/mixed-stack.md +24 -0
  452. package/zh/guides/topic-detail/micro-frontend/route-mode.md +110 -0
  453. package/zh/guides/topic-detail/model/_category_.json +4 -0
  454. package/zh/guides/topic-detail/model/auto-actions.md +90 -0
  455. package/zh/guides/topic-detail/model/computed-state.md +151 -0
  456. package/zh/guides/topic-detail/model/define-model.md +66 -0
  457. package/zh/guides/topic-detail/model/faq.md +43 -0
  458. package/zh/guides/topic-detail/model/manage-effects.md +259 -0
  459. package/zh/guides/topic-detail/model/model-communicate.md +219 -0
  460. package/zh/guides/topic-detail/model/performance.md +173 -0
  461. package/zh/guides/topic-detail/model/quick-start.md +112 -0
  462. package/zh/guides/topic-detail/model/redux-integration.md +21 -0
  463. package/zh/guides/topic-detail/model/test-model.md +43 -0
  464. package/zh/guides/topic-detail/model/typescript-best-practice.md +71 -0
  465. package/zh/guides/topic-detail/model/use-model.md +244 -0
  466. package/zh/guides/topic-detail/model/use-out-of-modernjs.md +51 -0
  467. package/zh/guides/topic-detail/monorepo/_category_.json +4 -0
  468. package/zh/guides/topic-detail/monorepo/create-sub-project.md +64 -0
  469. package/zh/guides/topic-detail/monorepo/deploy.md +43 -0
  470. package/zh/guides/topic-detail/monorepo/intro.md +15 -0
  471. package/zh/guides/topic-detail/monorepo/publish.md +68 -0
  472. package/zh/guides/topic-detail/monorepo/sub-project-interface.md +170 -0
  473. package/zh/guides/troubleshooting/_category_.json +5 -0
  474. package/zh/guides/troubleshooting/compile.md +379 -0
  475. package/zh/guides/troubleshooting/dependencies.md +168 -0
  476. package/zh/tutorials/first-app/_category_.json +5 -0
  477. package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +25 -0
  478. package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +118 -0
  479. package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +29 -0
  480. package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +44 -0
  481. package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +18 -0
  482. package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +31 -0
  483. package/zh/tutorials/first-app/c01-getting-started/_category_.json +3 -0
  484. package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +87 -0
  485. package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +28 -0
  486. package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +21 -0
  487. package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +3 -0
  488. package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +55 -0
  489. package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +66 -0
  490. package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +11 -0
  491. package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +63 -0
  492. package/zh/tutorials/first-app/c03-ide/_category_.json +3 -0
  493. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +67 -0
  494. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +111 -0
  495. package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +67 -0
  496. package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +3 -0
  497. package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +68 -0
  498. package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +92 -0
  499. package/zh/tutorials/first-app/c05-component/_category_.json +3 -0
  500. package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +110 -0
  501. package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +148 -0
  502. package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +84 -0
  503. package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +83 -0
  504. package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +77 -0
  505. package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +113 -0
  506. package/zh/tutorials/first-app/c06-css-and-component/_category_.json +3 -0
  507. package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +64 -0
  508. package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +104 -0
  509. package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +74 -0
  510. package/zh/tutorials/first-app/c07-app-entry/_category_.json +3 -0
  511. package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +153 -0
  512. package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +318 -0
  513. package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +3 -0
  514. package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +30 -0
  515. package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +93 -0
  516. package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +205 -0
  517. package/zh/tutorials/first-app/c09-bff/_category_.json +3 -0
  518. package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +23 -0
  519. package/zh/tutorials/first-app/c10-model/10.2-add-model.md +185 -0
  520. package/zh/tutorials/first-app/c10-model/10.3-use-model.md +54 -0
  521. package/zh/tutorials/first-app/c10-model/10.4-testing.md +69 -0
  522. package/zh/tutorials/first-app/c10-model/_category_.json +3 -0
  523. package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +274 -0
  524. package/zh/tutorials/first-app/c11-container/11.2-add-container.md +106 -0
  525. package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +61 -0
  526. package/zh/tutorials/first-app/c11-container/11.4-testing.md +56 -0
  527. package/zh/tutorials/first-app/c11-container/_category_.json +3 -0
  528. package/zh/tutorials/first-app/overview.md +11 -0
  529. package/zh/tutorials/foundations/_category_.json +5 -0
  530. package/zh/tutorials/foundations/basic.md +8 -0
  531. package/zh/tutorials/foundations/introduction.md +41 -0
@@ -0,0 +1,1156 @@
1
+ ---
2
+ title: source.designSystem
3
+ sidebar_label: designSystem
4
+ ---
5
+
6
+
7
+ :::caution 注意
8
+ 需要先通过 `pnpm run new` 启用 Tailwind CSS 功能。
9
+ :::
10
+
11
+
12
+ * 类型: `Object`
13
+ * 默认值:见下方配置详情。
14
+
15
+ <details>
16
+ <summary>designSystem 配置详情</summary>
17
+
18
+ ```js
19
+ const designSystem = {
20
+ screens: {
21
+ sm: '640px',
22
+ md: '768px',
23
+ lg: '1024px',
24
+ xl: '1280px',
25
+ },
26
+ colors: {
27
+ transparent: 'transparent',
28
+ current: 'currentColor',
29
+
30
+ black: '#000',
31
+ white: '#fff',
32
+
33
+ gray: {
34
+ 100: '#f7fafc',
35
+ 200: '#edf2f7',
36
+ 300: '#e2e8f0',
37
+ 400: '#cbd5e0',
38
+ 500: '#a0aec0',
39
+ 600: '#718096',
40
+ 700: '#4a5568',
41
+ 800: '#2d3748',
42
+ 900: '#1a202c',
43
+ },
44
+ red: {
45
+ 100: '#fff5f5',
46
+ 200: '#fed7d7',
47
+ 300: '#feb2b2',
48
+ 400: '#fc8181',
49
+ 500: '#f56565',
50
+ 600: '#e53e3e',
51
+ 700: '#c53030',
52
+ 800: '#9b2c2c',
53
+ 900: '#742a2a',
54
+ },
55
+ orange: {
56
+ 100: '#fffaf0',
57
+ 200: '#feebc8',
58
+ 300: '#fbd38d',
59
+ 400: '#f6ad55',
60
+ 500: '#ed8936',
61
+ 600: '#dd6b20',
62
+ 700: '#c05621',
63
+ 800: '#9c4221',
64
+ 900: '#7b341e',
65
+ },
66
+ yellow: {
67
+ 100: '#fffff0',
68
+ 200: '#fefcbf',
69
+ 300: '#faf089',
70
+ 400: '#f6e05e',
71
+ 500: '#ecc94b',
72
+ 600: '#d69e2e',
73
+ 700: '#b7791f',
74
+ 800: '#975a16',
75
+ 900: '#744210',
76
+ },
77
+ green: {
78
+ 100: '#f0fff4',
79
+ 200: '#c6f6d5',
80
+ 300: '#9ae6b4',
81
+ 400: '#68d391',
82
+ 500: '#48bb78',
83
+ 600: '#38a169',
84
+ 700: '#2f855a',
85
+ 800: '#276749',
86
+ 900: '#22543d',
87
+ },
88
+ teal: {
89
+ 100: '#e6fffa',
90
+ 200: '#b2f5ea',
91
+ 300: '#81e6d9',
92
+ 400: '#4fd1c5',
93
+ 500: '#38b2ac',
94
+ 600: '#319795',
95
+ 700: '#2c7a7b',
96
+ 800: '#285e61',
97
+ 900: '#234e52',
98
+ },
99
+ blue: {
100
+ 100: '#ebf8ff',
101
+ 200: '#bee3f8',
102
+ 300: '#90cdf4',
103
+ 400: '#63b3ed',
104
+ 500: '#4299e1',
105
+ 600: '#3182ce',
106
+ 700: '#2b6cb0',
107
+ 800: '#2c5282',
108
+ 900: '#2a4365',
109
+ },
110
+ indigo: {
111
+ 100: '#ebf4ff',
112
+ 200: '#c3dafe',
113
+ 300: '#a3bffa',
114
+ 400: '#7f9cf5',
115
+ 500: '#667eea',
116
+ 600: '#5a67d8',
117
+ 700: '#4c51bf',
118
+ 800: '#434190',
119
+ 900: '#3c366b',
120
+ },
121
+ purple: {
122
+ 100: '#faf5ff',
123
+ 200: '#e9d8fd',
124
+ 300: '#d6bcfa',
125
+ 400: '#b794f4',
126
+ 500: '#9f7aea',
127
+ 600: '#805ad5',
128
+ 700: '#6b46c1',
129
+ 800: '#553c9a',
130
+ 900: '#44337a',
131
+ },
132
+ pink: {
133
+ 100: '#fff5f7',
134
+ 200: '#fed7e2',
135
+ 300: '#fbb6ce',
136
+ 400: '#f687b3',
137
+ 500: '#ed64a6',
138
+ 600: '#d53f8c',
139
+ 700: '#b83280',
140
+ 800: '#97266d',
141
+ 900: '#702459',
142
+ },
143
+ },
144
+ spacing: {
145
+ px: '1px',
146
+ '0': '0',
147
+ '1': '0.25rem',
148
+ '2': '0.5rem',
149
+ '3': '0.75rem',
150
+ '4': '1rem',
151
+ '5': '1.25rem',
152
+ '6': '1.5rem',
153
+ '8': '2rem',
154
+ '10': '2.5rem',
155
+ '12': '3rem',
156
+ '16': '4rem',
157
+ '20': '5rem',
158
+ '24': '6rem',
159
+ '32': '8rem',
160
+ '40': '10rem',
161
+ '48': '12rem',
162
+ '56': '14rem',
163
+ '64': '16rem',
164
+ },
165
+ backgroundColor: theme => theme('colors'),
166
+ backgroundOpacity: theme => theme('opacity'),
167
+ backgroundPosition: {
168
+ bottom: 'bottom',
169
+ center: 'center',
170
+ left: 'left',
171
+ 'left-bottom': 'left bottom',
172
+ 'left-top': 'left top',
173
+ right: 'right',
174
+ 'right-bottom': 'right bottom',
175
+ 'right-top': 'right top',
176
+ top: 'top',
177
+ },
178
+ backgroundSize: {
179
+ auto: 'auto',
180
+ cover: 'cover',
181
+ contain: 'contain',
182
+ },
183
+ borderColor: theme => ({
184
+ ...theme('colors'),
185
+ default: theme('colors.gray.300', 'currentColor'),
186
+ }),
187
+ borderOpacity: theme => theme('opacity'),
188
+ borderRadius: {
189
+ none: '0',
190
+ sm: '0.125rem',
191
+ default: '0.25rem',
192
+ md: '0.375rem',
193
+ lg: '0.5rem',
194
+ full: '9999px',
195
+ },
196
+ borderWidth: {
197
+ default: '1px',
198
+ '0': '0',
199
+ '2': '2px',
200
+ '4': '4px',
201
+ '8': '8px',
202
+ },
203
+ boxShadow: {
204
+ xs: '0 0 0 1px rgba(0, 0, 0, 0.05)',
205
+ sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
206
+ default: '0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06)',
207
+ md: '0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06)',
208
+ lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05)',
209
+ xl: '0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)',
210
+ '2xl': '0 25px 50px -12px rgba(0, 0, 0, 0.25)',
211
+ inner: 'inset 0 2px 4px 0 rgba(0, 0, 0, 0.06)',
212
+ outline: '0 0 0 3px rgba(66, 153, 225, 0.5)',
213
+ none: 'none',
214
+ },
215
+ container: {},
216
+ cursor: {
217
+ auto: 'auto',
218
+ default: 'default',
219
+ pointer: 'pointer',
220
+ wait: 'wait',
221
+ text: 'text',
222
+ move: 'move',
223
+ 'not-allowed': 'not-allowed',
224
+ },
225
+ divideColor: theme => theme('borderColor'),
226
+ divideOpacity: theme => theme('borderOpacity'),
227
+ divideWidth: theme => theme('borderWidth'),
228
+ fill: {
229
+ current: 'currentColor',
230
+ },
231
+ flex: {
232
+ '1': '1 1 0%',
233
+ auto: '1 1 auto',
234
+ initial: '0 1 auto',
235
+ none: 'none',
236
+ },
237
+ flexGrow: {
238
+ '0': '0',
239
+ default: '1',
240
+ },
241
+ flexShrink: {
242
+ '0': '0',
243
+ default: '1',
244
+ },
245
+ fontFamily: {
246
+ sans: [
247
+ 'system-ui',
248
+ '-apple-system',
249
+ 'BlinkMacSystemFont',
250
+ '"Segoe UI"',
251
+ 'Roboto',
252
+ '"Helvetica Neue"',
253
+ 'Arial',
254
+ '"Noto Sans"',
255
+ 'sans-serif',
256
+ '"Apple Color Emoji"',
257
+ '"Segoe UI Emoji"',
258
+ '"Segoe UI Symbol"',
259
+ '"Noto Color Emoji"',
260
+ ],
261
+ serif: ['Georgia', 'Cambria', '"Times New Roman"', 'Times', 'serif'],
262
+ mono: ['Menlo', 'Monaco', 'Consolas', '"Liberation Mono"', '"Courier New"', 'monospace'],
263
+ },
264
+ fontSize: {
265
+ xs: '0.75rem',
266
+ sm: '0.875rem',
267
+ base: '1rem',
268
+ lg: '1.125rem',
269
+ xl: '1.25rem',
270
+ '2xl': '1.5rem',
271
+ '3xl': '1.875rem',
272
+ '4xl': '2.25rem',
273
+ '5xl': '3rem',
274
+ '6xl': '4rem',
275
+ },
276
+ fontWeight: {
277
+ hairline: '100',
278
+ thin: '200',
279
+ light: '300',
280
+ normal: '400',
281
+ medium: '500',
282
+ semibold: '600',
283
+ bold: '700',
284
+ extrabold: '800',
285
+ black: '900',
286
+ },
287
+ height: theme => ({
288
+ auto: 'auto',
289
+ ...theme('spacing'),
290
+ full: '100%',
291
+ screen: '100vh',
292
+ }),
293
+ inset: {
294
+ '0': '0',
295
+ auto: 'auto',
296
+ },
297
+ letterSpacing: {
298
+ tighter: '-0.05em',
299
+ tight: '-0.025em',
300
+ normal: '0',
301
+ wide: '0.025em',
302
+ wider: '0.05em',
303
+ widest: '0.1em',
304
+ },
305
+ lineHeight: {
306
+ none: '1',
307
+ tight: '1.25',
308
+ snug: '1.375',
309
+ normal: '1.5',
310
+ relaxed: '1.625',
311
+ loose: '2',
312
+ '3': '.75rem',
313
+ '4': '1rem',
314
+ '5': '1.25rem',
315
+ '6': '1.5rem',
316
+ '7': '1.75rem',
317
+ '8': '2rem',
318
+ '9': '2.25rem',
319
+ '10': '2.5rem',
320
+ },
321
+ listStyleType: {
322
+ none: 'none',
323
+ disc: 'disc',
324
+ decimal: 'decimal',
325
+ },
326
+ margin: (theme, { negative }) => ({
327
+ auto: 'auto',
328
+ ...theme('spacing'),
329
+ ...negative(theme('spacing')),
330
+ }),
331
+ maxHeight: {
332
+ full: '100%',
333
+ screen: '100vh',
334
+ },
335
+ maxWidth: (theme, { breakpoints }) => ({
336
+ none: 'none',
337
+ xs: '20rem',
338
+ sm: '24rem',
339
+ md: '28rem',
340
+ lg: '32rem',
341
+ xl: '36rem',
342
+ '2xl': '42rem',
343
+ '3xl': '48rem',
344
+ '4xl': '56rem',
345
+ '5xl': '64rem',
346
+ '6xl': '72rem',
347
+ full: '100%',
348
+ ...breakpoints(theme('screens')),
349
+ }),
350
+ minHeight: {
351
+ '0': '0',
352
+ full: '100%',
353
+ screen: '100vh',
354
+ },
355
+ minWidth: {
356
+ '0': '0',
357
+ full: '100%',
358
+ },
359
+ objectPosition: {
360
+ bottom: 'bottom',
361
+ center: 'center',
362
+ left: 'left',
363
+ 'left-bottom': 'left bottom',
364
+ 'left-top': 'left top',
365
+ right: 'right',
366
+ 'right-bottom': 'right bottom',
367
+ 'right-top': 'right top',
368
+ top: 'top',
369
+ },
370
+ opacity: {
371
+ '0': '0',
372
+ '25': '0.25',
373
+ '50': '0.5',
374
+ '75': '0.75',
375
+ '100': '1',
376
+ },
377
+ order: {
378
+ first: '-9999',
379
+ last: '9999',
380
+ none: '0',
381
+ '1': '1',
382
+ '2': '2',
383
+ '3': '3',
384
+ '4': '4',
385
+ '5': '5',
386
+ '6': '6',
387
+ '7': '7',
388
+ '8': '8',
389
+ '9': '9',
390
+ '10': '10',
391
+ '11': '11',
392
+ '12': '12',
393
+ },
394
+ padding: theme => theme('spacing'),
395
+ placeholderColor: theme => theme('colors'),
396
+ placeholderOpacity: theme => theme('opacity'),
397
+ space: (theme, { negative }) => ({
398
+ ...theme('spacing'),
399
+ ...negative(theme('spacing')),
400
+ }),
401
+ stroke: {
402
+ current: 'currentColor',
403
+ },
404
+ strokeWidth: {
405
+ '0': '0',
406
+ '1': '1',
407
+ '2': '2',
408
+ },
409
+ textColor: theme => theme('colors'),
410
+ textOpacity: theme => theme('opacity'),
411
+ width: theme => ({
412
+ auto: 'auto',
413
+ ...theme('spacing'),
414
+ '1/2': '50%',
415
+ '1/3': '33.333333%',
416
+ '2/3': '66.666667%',
417
+ '1/4': '25%',
418
+ '2/4': '50%',
419
+ '3/4': '75%',
420
+ '1/5': '20%',
421
+ '2/5': '40%',
422
+ '3/5': '60%',
423
+ '4/5': '80%',
424
+ '1/6': '16.666667%',
425
+ '2/6': '33.333333%',
426
+ '3/6': '50%',
427
+ '4/6': '66.666667%',
428
+ '5/6': '83.333333%',
429
+ '1/12': '8.333333%',
430
+ '2/12': '16.666667%',
431
+ '3/12': '25%',
432
+ '4/12': '33.333333%',
433
+ '5/12': '41.666667%',
434
+ '6/12': '50%',
435
+ '7/12': '58.333333%',
436
+ '8/12': '66.666667%',
437
+ '9/12': '75%',
438
+ '10/12': '83.333333%',
439
+ '11/12': '91.666667%',
440
+ full: '100%',
441
+ screen: '100vw',
442
+ }),
443
+ zIndex: {
444
+ auto: 'auto',
445
+ '0': '0',
446
+ '10': '10',
447
+ '20': '20',
448
+ '30': '30',
449
+ '40': '40',
450
+ '50': '50',
451
+ },
452
+ gap: theme => theme('spacing'),
453
+ gridTemplateColumns: {
454
+ none: 'none',
455
+ '1': 'repeat(1, minmax(0, 1fr))',
456
+ '2': 'repeat(2, minmax(0, 1fr))',
457
+ '3': 'repeat(3, minmax(0, 1fr))',
458
+ '4': 'repeat(4, minmax(0, 1fr))',
459
+ '5': 'repeat(5, minmax(0, 1fr))',
460
+ '6': 'repeat(6, minmax(0, 1fr))',
461
+ '7': 'repeat(7, minmax(0, 1fr))',
462
+ '8': 'repeat(8, minmax(0, 1fr))',
463
+ '9': 'repeat(9, minmax(0, 1fr))',
464
+ '10': 'repeat(10, minmax(0, 1fr))',
465
+ '11': 'repeat(11, minmax(0, 1fr))',
466
+ '12': 'repeat(12, minmax(0, 1fr))',
467
+ },
468
+ gridColumn: {
469
+ auto: 'auto',
470
+ 'span-1': 'span 1 / span 1',
471
+ 'span-2': 'span 2 / span 2',
472
+ 'span-3': 'span 3 / span 3',
473
+ 'span-4': 'span 4 / span 4',
474
+ 'span-5': 'span 5 / span 5',
475
+ 'span-6': 'span 6 / span 6',
476
+ 'span-7': 'span 7 / span 7',
477
+ 'span-8': 'span 8 / span 8',
478
+ 'span-9': 'span 9 / span 9',
479
+ 'span-10': 'span 10 / span 10',
480
+ 'span-11': 'span 11 / span 11',
481
+ 'span-12': 'span 12 / span 12',
482
+ },
483
+ gridColumnStart: {
484
+ auto: 'auto',
485
+ '1': '1',
486
+ '2': '2',
487
+ '3': '3',
488
+ '4': '4',
489
+ '5': '5',
490
+ '6': '6',
491
+ '7': '7',
492
+ '8': '8',
493
+ '9': '9',
494
+ '10': '10',
495
+ '11': '11',
496
+ '12': '12',
497
+ '13': '13',
498
+ },
499
+ gridColumnEnd: {
500
+ auto: 'auto',
501
+ '1': '1',
502
+ '2': '2',
503
+ '3': '3',
504
+ '4': '4',
505
+ '5': '5',
506
+ '6': '6',
507
+ '7': '7',
508
+ '8': '8',
509
+ '9': '9',
510
+ '10': '10',
511
+ '11': '11',
512
+ '12': '12',
513
+ '13': '13',
514
+ },
515
+ gridTemplateRows: {
516
+ none: 'none',
517
+ '1': 'repeat(1, minmax(0, 1fr))',
518
+ '2': 'repeat(2, minmax(0, 1fr))',
519
+ '3': 'repeat(3, minmax(0, 1fr))',
520
+ '4': 'repeat(4, minmax(0, 1fr))',
521
+ '5': 'repeat(5, minmax(0, 1fr))',
522
+ '6': 'repeat(6, minmax(0, 1fr))',
523
+ },
524
+ gridRow: {
525
+ auto: 'auto',
526
+ 'span-1': 'span 1 / span 1',
527
+ 'span-2': 'span 2 / span 2',
528
+ 'span-3': 'span 3 / span 3',
529
+ 'span-4': 'span 4 / span 4',
530
+ 'span-5': 'span 5 / span 5',
531
+ 'span-6': 'span 6 / span 6',
532
+ },
533
+ gridRowStart: {
534
+ auto: 'auto',
535
+ '1': '1',
536
+ '2': '2',
537
+ '3': '3',
538
+ '4': '4',
539
+ '5': '5',
540
+ '6': '6',
541
+ '7': '7',
542
+ },
543
+ gridRowEnd: {
544
+ auto: 'auto',
545
+ '1': '1',
546
+ '2': '2',
547
+ '3': '3',
548
+ '4': '4',
549
+ '5': '5',
550
+ '6': '6',
551
+ '7': '7',
552
+ },
553
+ transformOrigin: {
554
+ center: 'center',
555
+ top: 'top',
556
+ 'top-right': 'top right',
557
+ right: 'right',
558
+ 'bottom-right': 'bottom right',
559
+ bottom: 'bottom',
560
+ 'bottom-left': 'bottom left',
561
+ left: 'left',
562
+ 'top-left': 'top left',
563
+ },
564
+ scale: {
565
+ '0': '0',
566
+ '50': '.5',
567
+ '75': '.75',
568
+ '90': '.9',
569
+ '95': '.95',
570
+ '100': '1',
571
+ '105': '1.05',
572
+ '110': '1.1',
573
+ '125': '1.25',
574
+ '150': '1.5',
575
+ },
576
+ rotate: {
577
+ '-180': '-180deg',
578
+ '-90': '-90deg',
579
+ '-45': '-45deg',
580
+ '0': '0',
581
+ '45': '45deg',
582
+ '90': '90deg',
583
+ '180': '180deg',
584
+ },
585
+ translate: (theme, { negative }) => ({
586
+ ...theme('spacing'),
587
+ ...negative(theme('spacing')),
588
+ '-full': '-100%',
589
+ '-1/2': '-50%',
590
+ '1/2': '50%',
591
+ full: '100%',
592
+ }),
593
+ skew: {
594
+ '-12': '-12deg',
595
+ '-6': '-6deg',
596
+ '-3': '-3deg',
597
+ '0': '0',
598
+ '3': '3deg',
599
+ '6': '6deg',
600
+ '12': '12deg',
601
+ },
602
+ transitionProperty: {
603
+ none: 'none',
604
+ all: 'all',
605
+ default: 'background-color, border-color, color, fill, stroke, opacity, box-shadow, transform',
606
+ colors: 'background-color, border-color, color, fill, stroke',
607
+ opacity: 'opacity',
608
+ shadow: 'box-shadow',
609
+ transform: 'transform',
610
+ },
611
+ transitionTimingFunction: {
612
+ linear: 'linear',
613
+ in: 'cubic-bezier(0.4, 0, 1, 1)',
614
+ out: 'cubic-bezier(0, 0, 0.2, 1)',
615
+ 'in-out': 'cubic-bezier(0.4, 0, 0.2, 1)',
616
+ },
617
+ transitionDuration: {
618
+ '75': '75ms',
619
+ '100': '100ms',
620
+ '150': '150ms',
621
+ '200': '200ms',
622
+ '300': '300ms',
623
+ '500': '500ms',
624
+ '700': '700ms',
625
+ '1000': '1000ms',
626
+ },
627
+ transitionDelay: {
628
+ '75': '75ms',
629
+ '100': '100ms',
630
+ '150': '150ms',
631
+ '200': '200ms',
632
+ '300': '300ms',
633
+ '500': '500ms',
634
+ '700': '700ms',
635
+ '1000': '1000ms',
636
+ },
637
+ };
638
+ ```
639
+
640
+ :::tip 提示
641
+ 更多关于:<a href="https://tailwindcss.com/docs/configuration#theme" target="_blank">TailwindCSS 配置</a>。
642
+ :::
643
+ </details>
644
+
645
+
646
+ `designSystem` 用于定义项目的调色板、排版比例(Typographic Scales 或者 Type Scale)、字体列表、断点、边框圆角值等等。因为 Modern.js 借用了 Tailwind Theme 的设计方式,并且内部也集成了 Tailwind CSS,所以 `designSystem` 使用方式与 Tailwind CSS Theme 相同
647
+
648
+ ### 结构
649
+
650
+ `designSystem` 对象包含 `screens`、`colors` 和 `spacing` 的属性,以及每个可自定义核心插件。
651
+
652
+ #### Screens
653
+
654
+ 使用`screens` 可以自定义项目中的响应断点:
655
+
656
+ ```js
657
+ const designSystem = {
658
+ screens: {
659
+ sm: '640px',
660
+ md: '768px',
661
+ lg: '1024px',
662
+ xl: '1280px',
663
+ },
664
+ };
665
+ ```
666
+
667
+ 其中 `screens` 对象里的属性名是屏幕名称(用作 `Tailwind CSS` 生成的自适应实用程序变体的前缀,例如 `md:text-center`),值是该断点应在其开始的 `min-width`。
668
+
669
+ 默认断点受常见设备分辨率的启发:
670
+
671
+ ```js
672
+ const designSystem = {
673
+ screens: {
674
+ sm: '640px',
675
+ // => @media (min-width: 640px) { ... }
676
+
677
+ md: '768px',
678
+ // => @media (min-width: 768px) { ... }
679
+
680
+ lg: '1024px',
681
+ // => @media (min-width: 1024px) { ... }
682
+
683
+ xl: '1280px',
684
+ // => @media (min-width: 1280px) { ... }
685
+ },
686
+ };
687
+ ```
688
+
689
+ 你可以在你的项目中使用任意你喜欢的名称作为断点的属性:
690
+
691
+ ```js
692
+ const designSystem = {
693
+ screens: {
694
+ tablet: '640px',
695
+ // => @media (min-width: 640px) { ... }
696
+
697
+ laptop: '1024px',
698
+ // => @media (min-width: 1024px) { ... }
699
+
700
+ desktop: '1280px',
701
+ // => @media (min-width: 1280px) { ... }
702
+ },
703
+ };
704
+ ```
705
+
706
+ 这些屏幕名称反映在 `utilities` 中,因此 `text-center` 现在是这样的:
707
+
708
+ ```css
709
+ .text-center { text-align: center }
710
+
711
+ @media (min-width: 640px) {
712
+ .tablet\:text-center { text-align: center }
713
+ }
714
+
715
+ @media (min-width: 1024px) {
716
+ .laptop\:text-center { text-align: center }
717
+ }
718
+
719
+ @media (min-width: 1280px) {
720
+ .desktop\:text-center { text-align: center }
721
+ }
722
+ ```
723
+
724
+ ##### Max-width 断点
725
+
726
+ 如果要使用 `max-width` 断点而不是 `min-width`,可以将屏幕指定为具有 `max` 属性的对象:
727
+
728
+ ```js
729
+ const designSystem = {
730
+ screens: {
731
+ xl: { max: '1279px' },
732
+ // => @media (max-width: 1279px) { ... }
733
+
734
+ lg: { max: '1023px' },
735
+ // => @media (max-width: 1023px) { ... }
736
+
737
+ md: { max: '767px' },
738
+ // => @media (max-width: 767px) { ... }
739
+
740
+ sm: { max: '639px' },
741
+ // => @media (max-width: 639px) { ... }
742
+ },
743
+ };
744
+ ```
745
+
746
+ 如有必要,以创建带有 `min-width` 和 `max-width` 定义的断点,例如:
747
+
748
+ ```js
749
+ const designSystem = {
750
+ screens: {
751
+ sm: { min: '640px', max: '767px' },
752
+ md: { min: '768px', max: '1023px' },
753
+ lg: { min: '1024px', max: '1279px' },
754
+ xl: { min: '1280px' },
755
+ },
756
+ };
757
+ ```
758
+
759
+ ##### 多个范围的断点
760
+
761
+ 有时,将单个断点定义应用于多个范围会很有用。
762
+
763
+ 例如,假设您有一个 `sidebar`,并且希望断点基于内容区域宽度而不是整个视口。您可以模拟这种情况,当 `sidebar` 可见并缩小内容区域时,断点的样式使用较小的断点样式:
764
+
765
+ ```js
766
+ const designSystem = {
767
+ screens: {
768
+ sm: '500px',
769
+ md: [
770
+ // Sidebar appears at 768px, so revert to `sm:` styles between 768px
771
+ // and 868px, after which the main content area is wide enough again to
772
+ // apply the `md:` styles.
773
+ { min: '668px', max: '767px' },
774
+ { min: '868px' },
775
+ ],
776
+ lg: '1100px',
777
+ xl: '1400px',
778
+ },
779
+ };
780
+ ```
781
+
782
+ ##### 自定义媒体查询
783
+
784
+ 如果需要为断点提供完全自定义的媒体查询,则可以使用带有 `raw` 属性的对象:
785
+
786
+ ```js
787
+ const designSystem = {
788
+ extend: {
789
+ screens: {
790
+ portrait: { raw: '(orientation: portrait)' },
791
+ // => @media (orientation: portrait) { ... }
792
+ },
793
+ },
794
+ };
795
+ ```
796
+
797
+ ##### Print 样式
798
+
799
+ 如果需要为打印应用不同的样式,则 `raw` 选项可能特别有用。
800
+
801
+ 需要做的就是在 `designSystem.extend.screens` 下添加一个 `print`:
802
+
803
+ ```js
804
+ const designSystem = {
805
+ extend: {
806
+ screens: {
807
+ print: { raw: 'print' },
808
+ // => @media print { ... }
809
+ },
810
+ },
811
+ };
812
+ ```
813
+
814
+ 然后,可以使用诸如 `print:text-black` 之类的类来指定仅当某人尝试打印页面时才应用的样式:
815
+
816
+ ```html
817
+ <div class="text-gray-700 print:text-black">
818
+ <!-- ... -->
819
+ </div>
820
+ ```
821
+
822
+ ##### Dark Mode
823
+
824
+ `raw` 选项可以用于实现 “暗模式” 屏幕:
825
+
826
+ ```js
827
+ const designSystem = {
828
+ extend: {
829
+ screens: {
830
+ dark: { raw: '(prefers-color-scheme: dark)' },
831
+ // => @media (prefers-color-scheme: dark) { ... }
832
+ },
833
+ },
834
+ };
835
+ ```
836
+
837
+ 然后,您可以使用 `dark:` 前缀在暗模式下为元素设置不同的样式:
838
+
839
+ ```html
840
+ <div class="text-gray-700 dark:text-gray-200">
841
+ <!-- ... -->
842
+ </div>
843
+ ```
844
+
845
+ 请注意,由于这些 `screen variants` 是在 `Tailwind CSS` 中实现的,因此**无法使用这种方法将断点与暗模式结合使用** ,例如 `md:dark:text-gray-300` 将不起作用。
846
+
847
+ #### Colors
848
+
849
+ `colors` 属性可让您自定义项目的全局调色板。
850
+
851
+ ```js
852
+ const designSystem = {
853
+ colors: {
854
+ transparent: 'transparent',
855
+ black: '#000',
856
+ white: '#fff',
857
+ gray: {
858
+ 100: '#f7fafc',
859
+ // ...
860
+ 900: '#1a202c',
861
+ },
862
+
863
+ // ...
864
+ },
865
+ };
866
+ ```
867
+
868
+ 默认情况下,这些颜色由 `backgroundColor`,`textColor` 和 `borderColor` 核心插件继承。
869
+
870
+ 想了解更多,可以查看:[Customizing Colors](https://tailwindcss.com/docs/customizing-colors)。
871
+
872
+ #### Spacing
873
+
874
+ 使用 `space` 属性,可以自定义项目的全局间距和缩放比例:
875
+
876
+ ```js
877
+ const designSystem = {
878
+ spacing: {
879
+ px: '1px',
880
+ 0: '0',
881
+ 1: '0.25rem',
882
+ 2: '0.5rem',
883
+ 3: '0.75rem',
884
+ 4: '1rem',
885
+ 5: '1.25rem',
886
+ 6: '1.5rem',
887
+ 8: '2rem',
888
+ 10: '2.5rem',
889
+ 12: '3rem',
890
+ 16: '4rem',
891
+ 20: '5rem',
892
+ 24: '6rem',
893
+ 32: '8rem',
894
+ 40: '10rem',
895
+ 48: '12rem',
896
+ 56: '14rem',
897
+ 64: '16rem',
898
+ },
899
+ };
900
+ ```
901
+
902
+ 默认情况下,这些值由 `padding`,`margin`,`negativeMargin`,`width` 和 `height` 核心插件继承。
903
+
904
+ 想要了解更多,看 [Customizing Spacing](https://tailwindcss.com/docs/customizing-spacing)。
905
+
906
+ #### Core plugins
907
+
908
+ 主题部分的其余部分用于配置每个核心插件可用的值。
909
+
910
+ 例如,`borderRadius` 属性可让您自定义将生成的圆角的 `utilities`:
911
+
912
+ ```js
913
+ const designSystem = {
914
+ borderRadius: {
915
+ none: '0',
916
+ sm: '.125rem',
917
+ default: '.25rem',
918
+ lg: '.5rem',
919
+ full: '9999px',
920
+ },
921
+ };
922
+ ```
923
+
924
+ **属性名确定所生成类的后缀,值确定实际CSS声明的值。**上面的示例`borderRadius`配置将生成以下CSS类:
925
+
926
+ ```css
927
+ .rounded-none { border-radius: 0 }
928
+ .rounded-sm { border-radius: .125rem }
929
+ .rounded { border-radius: .25rem }
930
+ .rounded-lg { border-radius: .5rem }
931
+ .rounded-full { border-radius: 9999px }
932
+ ```
933
+
934
+ 会注意到,在主题配置中使用 `default` 属性创建了不带后缀的 `rounded` 类。这是许多(尽管不是全部)核心插件支持的 Tailwind CSS 中的通用约定。
935
+
936
+ 要了解有关自定义特定核心插件的更多信息,请访问该插件的文档。
937
+
938
+ ### 自定义默认配置
939
+
940
+ 开箱即用,您的项目将自动从默认主题配置继承值。如果想自定义默认主题,则根据目标有几种不同的选择。
941
+
942
+ #### 覆盖默认配置
943
+
944
+ 要覆盖默认配置中的选项,请在 `designSystem` 中添加要覆盖的属性:
945
+
946
+ ```js title="modern.config.js"
947
+ const designSystem = {
948
+ // Replaces all of the default `opacity` values
949
+ opacity: {
950
+ 0: '0',
951
+ 20: '0.2',
952
+ 40: '0.4',
953
+ 60: '0.6',
954
+ 80: '0.8',
955
+ 100: '1',
956
+ },
957
+ };
958
+
959
+ export default defineConfig({
960
+ source: {
961
+ designSystem,
962
+ },
963
+ });
964
+ ```
965
+
966
+ 这将完全替换默认属性配置,因此在上面的示例中,不会生成默认的 `opacity utilities`。
967
+
968
+ 您未提供的任何属性都将从默认主题继承,因此在上面的示例中,将保留颜色,间距,边框圆角,背景位置等内容的默认主题配置。
969
+
970
+ #### 扩展默认配置
971
+
972
+ 如果您想保留主题选项的默认值,但又要添加新值,请在 `designSystem.extend` 属性下添加扩展的内容。
973
+
974
+ 例如,如果您想添加一个额外的断点但保留现有的断点,则可以扩展 `screens` 属性:
975
+
976
+ ```js title="modern.config.js"
977
+ const designSystem = {
978
+ extend: {
979
+ // Adds a new breakpoint in addition to the default breakpoints
980
+ screens: {
981
+ '2xl': '1440px',
982
+ },
983
+ },
984
+ };
985
+
986
+ export default defineConfig({
987
+ source: {
988
+ designSystem,
989
+ },
990
+ });
991
+ ```
992
+
993
+ 您当然可以覆盖默认主题的某些部分,并在同一配置中扩展默认主题的其他部分:
994
+
995
+ ```js title="modern.config.js"
996
+ const designSystem = {
997
+ opacity: {
998
+ 0: '0',
999
+ 20: '0.2',
1000
+ 40: '0.4',
1001
+ 60: '0.6',
1002
+ 80: '0.8',
1003
+ 100: '1',
1004
+ },
1005
+ extend: {
1006
+ screens: {
1007
+ '2xl': '1440px',
1008
+ },
1009
+ },
1010
+ };
1011
+
1012
+ export default defineConfig({
1013
+ source: {
1014
+ designSystem,
1015
+ },
1016
+ });
1017
+ ```
1018
+
1019
+ #### 引用其他值
1020
+
1021
+ 如果需要在配置中引用另一个值,可以通过提供闭包函数而不是静态值来实现。函数将收到 `theme()` 函数作为参数,您可以使用该函数使用点表示法在配置中查找其他值。
1022
+
1023
+ 例如,您可以在 `fill` 配置上通过引用 `theme('colors')` 为调色板中的每种颜色生成 `fill` utilities。
1024
+
1025
+ ```js title="modern.config.js"
1026
+ const designSystem = {
1027
+ colors: {
1028
+ // ...
1029
+ },
1030
+ fill: theme => theme('colors'),
1031
+ };
1032
+
1033
+ export default defineConfig({
1034
+ source: {
1035
+ designSystem,
1036
+ },
1037
+ });
1038
+ ```
1039
+
1040
+ `theme()`函数尝试从已经完全合并的配置对象中找到您要查找的值,因此它可以引用您自己的自定义设置以及默认主题值。它也可以递归工作,因此只要链末尾有一个静态值,它就可以解析您要查找的值。
1041
+
1042
+ **引用默认配置**
1043
+
1044
+ 如果出于任何原因想要引用默认配置中的值,则可以从 `tailwindcss/defaultTheme` 导入它。一个有用的示例是,如果要将添加默认配置提供的字体中某一个字体:
1045
+
1046
+ ```js title="modern.config.js"
1047
+ const defaultTheme = require('tailwindcss/defaultTheme');
1048
+
1049
+ const designSystem = {
1050
+ extend: {
1051
+ fontFamily: {
1052
+ sans: ['Lato', ...defaultTheme.fontFamily.sans],
1053
+ },
1054
+ },
1055
+ };
1056
+
1057
+ export default defineConfig({
1058
+ source: {
1059
+ designSystem,
1060
+ },
1061
+ });
1062
+ ```
1063
+
1064
+ #### 禁用整个核心插件
1065
+
1066
+ 如果您不想为某个核心插件生成任何类,则最好在 `corePlugins` 配置中将该插件设置为 `false`,而不是在配置中为该属性提供一个空对象:
1067
+
1068
+ ```js
1069
+ // Don't assign an empty object in your theme configuration
1070
+
1071
+ const designSystem = {
1072
+ opacity: {},
1073
+ };
1074
+
1075
+ // Do disable the plugin in your corePlugins configuration
1076
+ const designSyttem = {
1077
+ corePlugins: {
1078
+ opacity: false,
1079
+ },
1080
+ };
1081
+ ```
1082
+
1083
+ 最终结果是相同的,但是由于许多核心插件未公开任何配置,因此无论如何只能使用 corePlugins 禁用它们,最好保持一致。
1084
+
1085
+ #### 添加自己的key
1086
+
1087
+ 在很多情况下,将自己的属性添加到配置对象可能会很有用。
1088
+
1089
+ 其中一个示例是添加新属性为多个核心插件之间复用。例如,您可以提取一个 `positions`对象,`backgroundPosition` 和 `objectPosition` 插件都可以引用该对象:
1090
+
1091
+ ```js
1092
+ const designSystem = {
1093
+ positions: {
1094
+ bottom: 'bottom',
1095
+ center: 'center',
1096
+ left: 'left',
1097
+ 'left-bottom': 'left bottom',
1098
+ 'left-top': 'left top',
1099
+ right: 'right',
1100
+ 'right-bottom': 'right bottom',
1101
+ 'right-top': 'right top',
1102
+ top: 'top',
1103
+ },
1104
+ backgroundPosition: theme => theme('positions'),
1105
+ objectPosition: theme => theme('positions'),
1106
+ };
1107
+ ```
1108
+
1109
+ 另一个示例是在自定义插件中添加新的属性以进行引用。例如,如果您为项目编写了渐变插件,则可以向该插件引用的主题对象添加渐变属性:
1110
+
1111
+ ```js title="modern.config.js"
1112
+ const designSystem = {
1113
+ gradients: theme => ({
1114
+ 'blue-green': [theme('colors.blue.500'), theme('colors.green.500')],
1115
+ 'purple-blue': [theme('colors.purple.500'), theme('colors.blue.500')],
1116
+ // ...
1117
+ }),
1118
+ };
1119
+
1120
+ export default defineConfig({
1121
+ source: {
1122
+ designSystem,
1123
+ },
1124
+ tools: {
1125
+ tailwind: {
1126
+ plugins: [require('./plugins/gradients')],
1127
+ },
1128
+ },
1129
+ });
1130
+ ```
1131
+
1132
+ ### 配置引用
1133
+
1134
+ 除了 `screens`,`colors` 和 `spacing` 外,配置对象中的所有属性都映射到 `Tailwind CSS` 的核心插件上。由于许多插件负责仅接受静态值集(例如,例如`float`)的CSS属性,因此请注意,并非每个插件在主题对象中都有对应的属性。
1135
+
1136
+ 所有这些属性也可以在 `designSystem.extend` 属性下使用,以扩展默认主题。
1137
+
1138
+ 关于所有属性的作用,可以查看此 [链接](https://tailwindcss.com/docs/theme#configuration-reference)。
1139
+
1140
+ ### 额外的配置
1141
+
1142
+ 除了与 Tailwind CSS Theme 相同的配置以外,还有 Modern.js 提供的额外的配置。
1143
+
1144
+ #### source.designSystem.supportStyledComponents
1145
+
1146
+ ##### 类型
1147
+
1148
+ `boolean`
1149
+
1150
+ ##### 默认值
1151
+
1152
+ `false`
1153
+
1154
+ ##### 说明
1155
+
1156
+ 值 `true` 时,运行时在应用外层提供 `styled-components` `ThemeProvider` 组件,并且将通过 `designSystem` 生成的 `Theme Token` 对象注入。