@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.
- package/.eslintrc.js +12 -0
- package/CHANGELOG.md +15 -0
- package/LICENSE +144 -0
- package/en/configure/app/dev/asset-prefix.md +13 -0
- package/en/configure/app/dev/hmr.md +13 -0
- package/en/configure/app/dev/https.md +13 -0
- package/en/configure/app/dev/port.md +13 -0
- package/en/configure/app/dev/progress-bar.md +13 -0
- package/en/configure/app/dev/start-url.md +13 -0
- package/en/configure/app/html/app-icon.md +13 -0
- package/en/configure/app/html/crossorigin.md +13 -0
- package/en/configure/app/html/disable-html-folder.md +13 -0
- package/en/configure/app/html/favicon-by-entries.md +13 -0
- package/en/configure/app/html/favicon.md +13 -0
- package/en/configure/app/html/inject-by-entries.md +13 -0
- package/en/configure/app/html/inject.md +13 -0
- package/en/configure/app/html/meta-by-entries.md +13 -0
- package/en/configure/app/html/meta.md +13 -0
- package/en/configure/app/html/mount-id.md +13 -0
- package/en/configure/app/html/template-by-entries.md +13 -0
- package/en/configure/app/html/template-parameters-by-entries.md +13 -0
- package/en/configure/app/html/template-parameters.md +13 -0
- package/en/configure/app/html/template.md +13 -0
- package/en/configure/app/html/title-by-entries.md +13 -0
- package/en/configure/app/html/title.md +13 -0
- package/en/configure/app/output/asset-prefix.md +13 -0
- package/en/configure/app/output/assets-retry.md +13 -0
- package/en/configure/app/output/charset.md +13 -0
- package/en/configure/app/output/clean-dist-path.md +13 -0
- package/en/configure/app/output/convert-to-rem.md +13 -0
- package/en/configure/app/output/copy.md +13 -0
- package/en/configure/app/output/css-module-local-ident-name.md +13 -0
- package/en/configure/app/output/data-uri-limit.md +13 -0
- package/en/configure/app/output/disable-css-module-extension.md +13 -0
- package/en/configure/app/output/disable-filename-hash.md +13 -0
- package/en/configure/app/output/disable-inline-runtime-chunk.md +13 -0
- package/en/configure/app/output/disable-minimize.md +13 -0
- package/en/configure/app/output/disable-source-map.md +13 -0
- package/en/configure/app/output/dist-path.md +13 -0
- package/en/configure/app/output/enable-asset-fallback.md +13 -0
- package/en/configure/app/output/enable-asset-manifest.md +13 -0
- package/en/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
- package/en/configure/app/output/enable-inline-scripts.md +13 -0
- package/en/configure/app/output/enable-inline-styles.md +13 -0
- package/en/configure/app/output/enable-latest-decorators.md +13 -0
- package/en/configure/app/output/externals.md +13 -0
- package/en/configure/app/output/filename.md +13 -0
- package/en/configure/app/output/legal-comments.md +13 -0
- package/en/configure/app/output/override-browserslist.md +13 -0
- package/en/configure/app/output/polyfill.md +13 -0
- package/en/configure/app/output/svg-default-export.md +13 -0
- package/en/configure/app/performance/build-cache.md +13 -0
- package/en/configure/app/performance/bundle-analyze.md +13 -0
- package/en/configure/app/performance/chunk-split.md +13 -0
- package/en/configure/app/performance/print-file-size.md +13 -0
- package/en/configure/app/performance/profile.md +13 -0
- package/en/configure/app/performance/remove-console.md +13 -0
- package/en/configure/app/performance/remove-moment-locale.md +13 -0
- package/en/configure/app/security/sri.md +13 -0
- package/en/configure/app/source/alias.md +13 -0
- package/en/configure/app/source/compile-js-data-uri.md +13 -0
- package/en/configure/app/source/define.md +13 -0
- package/en/configure/app/source/global-vars.md +13 -0
- package/en/configure/app/source/include.md +13 -0
- package/en/configure/app/source/module-scopes.md +13 -0
- package/en/configure/app/source/pre-entry.md +13 -0
- package/en/configure/app/source/resolve-extension-prefix.md +13 -0
- package/en/configure/app/source/resolve-main-fields.md +13 -0
- package/en/configure/app/tools/autoprefixer.md +13 -0
- package/en/configure/app/tools/babel.md +13 -0
- package/en/configure/app/tools/css-extract.md +13 -0
- package/en/configure/app/tools/css-loader.md +13 -0
- package/en/configure/app/tools/dev-server.md +13 -0
- package/en/configure/app/tools/html-plugin.md +13 -0
- package/en/configure/app/tools/inspector.md +13 -0
- package/en/configure/app/tools/less.md +13 -0
- package/en/configure/app/tools/minify-css.md +13 -0
- package/en/configure/app/tools/postcss.md +13 -0
- package/en/configure/app/tools/pug.md +13 -0
- package/en/configure/app/tools/sass.md +13 -0
- package/en/configure/app/tools/style-loader.md +13 -0
- package/en/configure/app/tools/styled-components.md +13 -0
- package/en/configure/app/tools/terser.md +13 -0
- package/en/configure/app/tools/ts-checker.md +13 -0
- package/en/configure/app/tools/ts-loader.md +13 -0
- package/en/configure/app/tools/webpack-chain.md +13 -0
- package/en/configure/app/tools/webpack.md +13 -0
- package/en/tutorials/foundations/_category_.json +5 -0
- package/en/tutorials/foundations/basic.md +8 -0
- package/en/tutorials/foundations/introduction.md +43 -0
- package/package.json +30 -0
- package/scripts/gen-config.ts +60 -0
- package/scripts/sync.ts +36 -0
- package/tsconfig.json +7 -0
- package/zh/apis/app/commands/_category_.json +8 -0
- package/zh/apis/app/commands/build.md +44 -0
- package/zh/apis/app/commands/dev.md +31 -0
- package/zh/apis/app/commands/index.md +12 -0
- package/zh/apis/app/commands/inspect.md +39 -0
- package/zh/apis/app/commands/lint.md +22 -0
- package/zh/apis/app/commands/new.md +59 -0
- package/zh/apis/app/commands/start.md +32 -0
- package/zh/apis/app/commands/test.md +36 -0
- package/zh/apis/app/commands/upgrade.md +23 -0
- package/zh/apis/app/hooks/_category_.json +8 -0
- package/zh/apis/app/hooks/api/_category_.json +4 -0
- package/zh/apis/app/hooks/api/framework/_category_.json +4 -0
- package/zh/apis/app/hooks/api/framework/app.md +100 -0
- package/zh/apis/app/hooks/api/framework/lambda.md +79 -0
- package/zh/apis/app/hooks/api/functions/_category_.json +4 -0
- package/zh/apis/app/hooks/api/functions/api.md +50 -0
- package/zh/apis/app/hooks/api/functions/app.md +10 -0
- package/zh/apis/app/hooks/api/functions/common.md +10 -0
- package/zh/apis/app/hooks/api/test.md +12 -0
- package/zh/apis/app/hooks/config/_category_.json +4 -0
- package/zh/apis/app/hooks/config/html.md +10 -0
- package/zh/apis/app/hooks/config/icon.md +17 -0
- package/zh/apis/app/hooks/config/mock.md +12 -0
- package/zh/apis/app/hooks/config/public.md +30 -0
- package/zh/apis/app/hooks/config/storybook.md +14 -0
- package/zh/apis/app/hooks/config/upload.md +48 -0
- package/zh/apis/app/hooks/index.md +12 -0
- package/zh/apis/app/hooks/modern-config.md +10 -0
- package/zh/apis/app/hooks/server/_category_.json +4 -0
- package/zh/apis/app/hooks/server/index.md +14 -0
- package/zh/apis/app/hooks/server/test.md +12 -0
- package/zh/apis/app/hooks/shared.md +8 -0
- package/zh/apis/app/hooks/src/_category_.json +4 -0
- package/zh/apis/app/hooks/src/app.md +41 -0
- package/zh/apis/app/hooks/src/error.md +10 -0
- package/zh/apis/app/hooks/src/eslint.md +9 -0
- package/zh/apis/app/hooks/src/index.md +35 -0
- package/zh/apis/app/hooks/src/pages.md +183 -0
- package/zh/apis/app/hooks/src/stories.md +14 -0
- package/zh/apis/app/hooks/src/test.md +12 -0
- package/zh/apis/app/overview.md +11 -0
- package/zh/apis/app/runtime/_category_.json +9 -0
- package/zh/apis/app/runtime/app/_category_.json +4 -0
- package/zh/apis/app/runtime/app/bootstrap.md +83 -0
- package/zh/apis/app/runtime/app/create-app.md +47 -0
- package/zh/apis/app/runtime/app/define-config.md +57 -0
- package/zh/apis/app/runtime/app/head.md +43 -0
- package/zh/apis/app/runtime/app/no-ssr.md +41 -0
- package/zh/apis/app/runtime/app/pre-render.md +77 -0
- package/zh/apis/app/runtime/app/use-module-app.md +60 -0
- package/zh/apis/app/runtime/app/use-module-apps.md +64 -0
- package/zh/apis/app/runtime/app/use-runtime-context.md +39 -0
- package/zh/apis/app/runtime/bff-server/_category_.json +4 -0
- package/zh/apis/app/runtime/bff-server/after-lambda-registed.md +35 -0
- package/zh/apis/app/runtime/bff-server/hook.md +120 -0
- package/zh/apis/app/runtime/bff-server/use-context.md +70 -0
- package/zh/apis/app/runtime/container/_category_.json +4 -0
- package/zh/apis/app/runtime/container/router.md +492 -0
- package/zh/apis/app/runtime/container/use-loader.md +64 -0
- package/zh/apis/app/runtime/default-alias.md +26 -0
- package/zh/apis/app/runtime/env.md +68 -0
- package/zh/apis/app/runtime/index.md +12 -0
- package/zh/apis/app/runtime/model/Provider.md +36 -0
- package/zh/apis/app/runtime/model/_category_.json +4 -0
- package/zh/apis/app/runtime/model/auto-actions.md +121 -0
- package/zh/apis/app/runtime/model/connect.md +134 -0
- package/zh/apis/app/runtime/model/create-app.md +74 -0
- package/zh/apis/app/runtime/model/create-store.md +60 -0
- package/zh/apis/app/runtime/model/handle-effect.md +106 -0
- package/zh/apis/app/runtime/model/model_.md +199 -0
- package/zh/apis/app/runtime/model/use-local-model.md +28 -0
- package/zh/apis/app/runtime/model/use-model.md +87 -0
- package/zh/apis/app/runtime/model/use-static-model.md +47 -0
- package/zh/apis/app/runtime/model/use-store.md +48 -0
- package/zh/apis/app/runtime/plugin/_category_.json +4 -0
- package/zh/apis/app/runtime/plugin/abstract.md +26 -0
- package/zh/apis/app/runtime/plugin/hook-api.md +896 -0
- package/zh/apis/app/runtime/plugin/hook.md +170 -0
- package/zh/apis/app/runtime/plugin/plugin-api.md +117 -0
- package/zh/apis/app/runtime/testing/_category_.json +4 -0
- package/zh/apis/app/runtime/testing/act.md +34 -0
- package/zh/apis/app/runtime/testing/cleanup.md +37 -0
- package/zh/apis/app/runtime/testing/render.md +52 -0
- package/zh/apis/app/runtime/testing/renderApp.md +31 -0
- package/zh/apis/app/runtime/utility/_category_.json +4 -0
- package/zh/apis/app/runtime/utility/css-in-js.md +60 -0
- package/zh/apis/app/runtime/utility/loadable/_category_.json +4 -0
- package/zh/apis/app/runtime/utility/loadable/lazy.md +29 -0
- package/zh/apis/app/runtime/utility/loadable/loadable-component.md +61 -0
- package/zh/apis/app/runtime/utility/loadable/loadable-library.md +67 -0
- package/zh/apis/app/runtime/utility/loadable/loadable_.md +110 -0
- package/zh/apis/app/runtime/web-server/_category_.json +4 -0
- package/zh/apis/app/runtime/web-server/hook.md +121 -0
- package/zh/apis/generator/overview.md +32 -0
- package/zh/apis/generator/plugin/_category_.json +4 -0
- package/zh/apis/generator/plugin/file/_category_.json +4 -0
- package/zh/apis/generator/plugin/file/addFile.md +52 -0
- package/zh/apis/generator/plugin/file/addHelper.md +26 -0
- package/zh/apis/generator/plugin/file/addManyFile.md +55 -0
- package/zh/apis/generator/plugin/file/addPartial.md +26 -0
- package/zh/apis/generator/plugin/file/introduce.md +37 -0
- package/zh/apis/generator/plugin/file/rmDir.md +24 -0
- package/zh/apis/generator/plugin/file/rmFile.md +24 -0
- package/zh/apis/generator/plugin/file/updateJSONFile.md +52 -0
- package/zh/apis/generator/plugin/file/updateModernConfig.md +26 -0
- package/zh/apis/generator/plugin/file/updateTextRawFile.md +33 -0
- package/zh/apis/generator/plugin/git/_category_.json +4 -0
- package/zh/apis/generator/plugin/git/gitAddAndCommit.md +20 -0
- package/zh/apis/generator/plugin/git/initGitRepo.md +16 -0
- package/zh/apis/generator/plugin/git/isInGitRepo.md +16 -0
- package/zh/apis/generator/plugin/hook/_category_.json +4 -0
- package/zh/apis/generator/plugin/hook/afterForged.md +35 -0
- package/zh/apis/generator/plugin/hook/onForged.md +35 -0
- package/zh/apis/generator/plugin/info/_category_.json +4 -0
- package/zh/apis/generator/plugin/info/isFileExit.md +22 -0
- package/zh/apis/generator/plugin/info/locale.md +17 -0
- package/zh/apis/generator/plugin/info/readDir.md +22 -0
- package/zh/apis/generator/plugin/input/_category_.json +4 -0
- package/zh/apis/generator/plugin/input/addInputAfter.md +48 -0
- package/zh/apis/generator/plugin/input/addInputBefore.md +48 -0
- package/zh/apis/generator/plugin/input/addOptionAfter.md +45 -0
- package/zh/apis/generator/plugin/input/addOptionBefore.md +45 -0
- package/zh/apis/generator/plugin/input/setInput.md +42 -0
- package/zh/apis/generator/plugin/input/setInputValue.md +28 -0
- package/zh/apis/generator/plugin/input/type.md +101 -0
- package/zh/apis/generator/plugin/introduce.md +93 -0
- package/zh/apis/generator/plugin/new/_category_.json +4 -0
- package/zh/apis/generator/plugin/new/createElement.md +33 -0
- package/zh/apis/generator/plugin/new/createSubProject.md +35 -0
- package/zh/apis/generator/plugin/new/enableFunc.md +46 -0
- package/zh/apis/generator/plugin/new/introduce.md +15 -0
- package/zh/apis/generator/plugin/npm/_category_.json +4 -0
- package/zh/apis/generator/plugin/npm/install.md +16 -0
- package/zh/apis/monorepo/commands/_category_.json +8 -0
- package/zh/apis/monorepo/commands/bump.md +42 -0
- package/zh/apis/monorepo/commands/change.md +58 -0
- package/zh/apis/monorepo/commands/clear.md +27 -0
- package/zh/apis/monorepo/commands/deploy.md +39 -0
- package/zh/apis/monorepo/commands/gen-release-note.md +35 -0
- package/zh/apis/monorepo/commands/index.md +12 -0
- package/zh/apis/monorepo/commands/lint.md +21 -0
- package/zh/apis/monorepo/commands/new.md +41 -0
- package/zh/apis/monorepo/commands/pre.md +68 -0
- package/zh/apis/monorepo/commands/release.md +20 -0
- package/zh/apis/monorepo/commands/upgrade.md +23 -0
- package/zh/apis/monorepo/hooks/_category_.json +8 -0
- package/zh/apis/monorepo/hooks/apps.md +12 -0
- package/zh/apis/monorepo/hooks/code-workspace.md +10 -0
- package/zh/apis/monorepo/hooks/examples.md +14 -0
- package/zh/apis/monorepo/hooks/features.md +14 -0
- package/zh/apis/monorepo/hooks/index.md +12 -0
- package/zh/apis/monorepo/hooks/packages.md +14 -0
- package/zh/apis/monorepo/hooks/pnpm-workspace.md +10 -0
- package/zh/apis/monorepo/hooks/pnpmfile.md +10 -0
- package/zh/apis/monorepo/overview.md +11 -0
- package/zh/community/index.md +3 -0
- package/zh/components/command-tip.md +57 -0
- package/zh/components/deploy.md +60 -0
- package/zh/components/dev-ide.md +1 -0
- package/zh/components/entry-name.md +15 -0
- package/zh/components/env-prepare.md +1 -0
- package/zh/components/launch-bff-choices.md +6 -0
- package/zh/components/reduck-tip.md +5 -0
- package/zh/configure/app/bff/_category_.json +4 -0
- package/zh/configure/app/bff/fetcher.md +32 -0
- package/zh/configure/app/bff/prefix.md +38 -0
- package/zh/configure/app/bff/proxy.md +76 -0
- package/zh/configure/app/dev/_category_.json +4 -0
- package/zh/configure/app/dev/asset-prefix.md +13 -0
- package/zh/configure/app/dev/hmr.md +13 -0
- package/zh/configure/app/dev/https.md +13 -0
- package/zh/configure/app/dev/port.md +13 -0
- package/zh/configure/app/dev/progress-bar.md +13 -0
- package/zh/configure/app/dev/proxy.md +79 -0
- package/zh/configure/app/dev/start-url.md +13 -0
- package/zh/configure/app/dev/with-master-app.md +35 -0
- package/zh/configure/app/html/app-icon.md +13 -0
- package/zh/configure/app/html/crossorigin.md +13 -0
- package/zh/configure/app/html/disable-html-folder.md +13 -0
- package/zh/configure/app/html/favicon-by-entries.md +13 -0
- package/zh/configure/app/html/favicon.md +13 -0
- package/zh/configure/app/html/inject-by-entries.md +13 -0
- package/zh/configure/app/html/inject.md +13 -0
- package/zh/configure/app/html/meta-by-entries.md +13 -0
- package/zh/configure/app/html/meta.md +13 -0
- package/zh/configure/app/html/mount-id.md +13 -0
- package/zh/configure/app/html/template-by-entries.md +13 -0
- package/zh/configure/app/html/template-parameters-by-entries.md +13 -0
- package/zh/configure/app/html/template-parameters.md +13 -0
- package/zh/configure/app/html/template.md +13 -0
- package/zh/configure/app/html/title-by-entries.md +13 -0
- package/zh/configure/app/html/title.md +13 -0
- package/zh/configure/app/output/_category_.json +4 -0
- package/zh/configure/app/output/asset-prefix.md +13 -0
- package/zh/configure/app/output/assets-retry.md +13 -0
- package/zh/configure/app/output/charset.md +13 -0
- package/zh/configure/app/output/clean-dist-path.md +13 -0
- package/zh/configure/app/output/convert-to-rem.md +13 -0
- package/zh/configure/app/output/copy.md +13 -0
- package/zh/configure/app/output/css-module-local-ident-name.md +13 -0
- package/zh/configure/app/output/data-uri-limit.md +13 -0
- package/zh/configure/app/output/disable-css-module-extension.md +13 -0
- package/zh/configure/app/output/disable-filename-hash.md +13 -0
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +13 -0
- package/zh/configure/app/output/disable-minimize.md +13 -0
- package/zh/configure/app/output/disable-node-polyfill.md +24 -0
- package/zh/configure/app/output/disable-source-map.md +13 -0
- package/zh/configure/app/output/dist-path.md +13 -0
- package/zh/configure/app/output/enable-asset-fallback.md +13 -0
- package/zh/configure/app/output/enable-asset-manifest.md +13 -0
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +13 -0
- package/zh/configure/app/output/enable-inline-scripts.md +13 -0
- package/zh/configure/app/output/enable-inline-styles.md +13 -0
- package/zh/configure/app/output/enable-latest-decorators.md +13 -0
- package/zh/configure/app/output/enable-modern-mode.md +26 -0
- package/zh/configure/app/output/externals.md +13 -0
- package/zh/configure/app/output/filename.md +13 -0
- package/zh/configure/app/output/legal-comments.md +13 -0
- package/zh/configure/app/output/override-browserslist.md +13 -0
- package/zh/configure/app/output/polyfill.md +13 -0
- package/zh/configure/app/output/ssg.md +226 -0
- package/zh/configure/app/output/svg-default-export.md +13 -0
- package/zh/configure/app/performance/build-cache.md +13 -0
- package/zh/configure/app/performance/bundle-analyze.md +13 -0
- package/zh/configure/app/performance/chunk-split.md +13 -0
- package/zh/configure/app/performance/print-file-size.md +13 -0
- package/zh/configure/app/performance/profile.md +13 -0
- package/zh/configure/app/performance/remove-console.md +13 -0
- package/zh/configure/app/performance/remove-moment-locale.md +13 -0
- package/zh/configure/app/plugins.md +74 -0
- package/zh/configure/app/runtime/_category_.json +4 -0
- package/zh/configure/app/runtime/master-app.md +72 -0
- package/zh/configure/app/runtime/router.md +54 -0
- package/zh/configure/app/runtime/state.md +45 -0
- package/zh/configure/app/security/sri.md +13 -0
- package/zh/configure/app/server/_category_.json +4 -0
- package/zh/configure/app/server/base-url.md +36 -0
- package/zh/configure/app/server/port.md +21 -0
- package/zh/configure/app/server/public-routes.md +29 -0
- package/zh/configure/app/server/routes.md +92 -0
- package/zh/configure/app/server/ssr-by-entries.md +32 -0
- package/zh/configure/app/server/ssr.md +24 -0
- package/zh/configure/app/source/_category_.json +4 -0
- package/zh/configure/app/source/alias.md +13 -0
- package/zh/configure/app/source/compile-js-data-uri.md +13 -0
- package/zh/configure/app/source/config-dir.md +15 -0
- package/zh/configure/app/source/define.md +13 -0
- package/zh/configure/app/source/design-system.md +1156 -0
- package/zh/configure/app/source/disable-default-entries.md +23 -0
- package/zh/configure/app/source/enable-async-entry.md +53 -0
- package/zh/configure/app/source/entries-dir.md +42 -0
- package/zh/configure/app/source/entries.md +55 -0
- package/zh/configure/app/source/global-vars.md +13 -0
- package/zh/configure/app/source/include.md +13 -0
- package/zh/configure/app/source/module-scopes.md +13 -0
- package/zh/configure/app/source/pre-entry.md +13 -0
- package/zh/configure/app/source/resolve-extension-prefix.md +13 -0
- package/zh/configure/app/source/resolve-main-fields.md +13 -0
- package/zh/configure/app/testing/_category_.json +4 -0
- package/zh/configure/app/testing/transformer.md +17 -0
- package/zh/configure/app/tools/_category_.json +4 -0
- package/zh/configure/app/tools/autoprefixer.md +13 -0
- package/zh/configure/app/tools/babel.md +13 -0
- package/zh/configure/app/tools/css-extract.md +13 -0
- package/zh/configure/app/tools/css-loader.md +13 -0
- package/zh/configure/app/tools/dev-server.md +13 -0
- package/zh/configure/app/tools/esbuild.md +61 -0
- package/zh/configure/app/tools/html-plugin.md +13 -0
- package/zh/configure/app/tools/inspector.md +13 -0
- package/zh/configure/app/tools/jest.md +41 -0
- package/zh/configure/app/tools/less.md +13 -0
- package/zh/configure/app/tools/minify-css.md +13 -0
- package/zh/configure/app/tools/postcss.md +13 -0
- package/zh/configure/app/tools/pug.md +13 -0
- package/zh/configure/app/tools/sass.md +13 -0
- package/zh/configure/app/tools/style-loader.md +13 -0
- package/zh/configure/app/tools/styled-components.md +13 -0
- package/zh/configure/app/tools/tailwindcss.md +48 -0
- package/zh/configure/app/tools/terser.md +13 -0
- package/zh/configure/app/tools/ts-checker.md +13 -0
- package/zh/configure/app/tools/ts-loader.md +13 -0
- package/zh/configure/app/tools/webpack-chain.md +13 -0
- package/zh/configure/app/tools/webpack.md +13 -0
- package/zh/configure/app/usage.md +81 -0
- package/zh/configure/generator/introduce.md +113 -0
- package/zh/configure/generator/module.md +43 -0
- package/zh/configure/generator/monorepo.md +28 -0
- package/zh/configure/generator/mwa.md +127 -0
- package/zh/guides/advanced-features/_category_.json +9 -0
- package/zh/guides/advanced-features/bff/_category_.json +4 -0
- package/zh/guides/advanced-features/bff/bff-proxy.md +25 -0
- package/zh/guides/advanced-features/bff/bff-server.md +142 -0
- package/zh/guides/advanced-features/bff/frameworks.md +348 -0
- package/zh/guides/advanced-features/bff/function.md +236 -0
- package/zh/guides/advanced-features/code-split.md +68 -0
- package/zh/guides/advanced-features/compatibility.md +89 -0
- package/zh/guides/advanced-features/custom-app.md +4 -0
- package/zh/guides/advanced-features/eslint.md +146 -0
- package/zh/guides/advanced-features/index.md +12 -0
- package/zh/guides/advanced-features/low-level.md +44 -0
- package/zh/guides/advanced-features/ssg.md +151 -0
- package/zh/guides/advanced-features/ssr.md +186 -0
- package/zh/guides/advanced-features/testing.md +4 -0
- package/zh/guides/advanced-features/typescript.md +4 -0
- package/zh/guides/advanced-features/web-server.md +135 -0
- package/zh/guides/basic-features/_category_.json +9 -0
- package/zh/guides/basic-features/alias.md +67 -0
- package/zh/guides/basic-features/css/_category_.json +4 -0
- package/zh/guides/basic-features/css/css-in-js.md +38 -0
- package/zh/guides/basic-features/css/css-modules.md +86 -0
- package/zh/guides/basic-features/css/less-sass.md +29 -0
- package/zh/guides/basic-features/css/postcss.md +81 -0
- package/zh/guides/basic-features/css/tailwindcss.md +98 -0
- package/zh/guides/basic-features/data-fetch.md +4 -0
- package/zh/guides/basic-features/env-vars.md +83 -0
- package/zh/guides/basic-features/html.md +128 -0
- package/zh/guides/basic-features/image.md +43 -0
- package/zh/guides/basic-features/index.md +12 -0
- package/zh/guides/basic-features/mock.md +85 -0
- package/zh/guides/basic-features/proxy.md +85 -0
- package/zh/guides/basic-features/routes.md +4 -0
- package/zh/guides/concept/_category_.json +5 -0
- package/zh/guides/concept/entries.md +4 -0
- package/zh/guides/concept/integrated.md +4 -0
- package/zh/guides/concept/lifecycle.md +4 -0
- package/zh/guides/concept/solutions.md +4 -0
- package/zh/guides/get-started/_category_.json +5 -0
- package/zh/guides/get-started/quick-start.md +4 -0
- package/zh/guides/get-started/upgrade.md +4 -0
- package/zh/guides/overview.md +11 -0
- package/zh/guides/topic-detail/_category_.json +5 -0
- package/zh/guides/topic-detail/changesets/_category_.json +4 -0
- package/zh/guides/topic-detail/changesets/add.md +125 -0
- package/zh/guides/topic-detail/changesets/changelog.md +239 -0
- package/zh/guides/topic-detail/changesets/commit.md +272 -0
- package/zh/guides/topic-detail/changesets/config.md +146 -0
- package/zh/guides/topic-detail/changesets/github.md +168 -0
- package/zh/guides/topic-detail/changesets/introduce.md +57 -0
- package/zh/guides/topic-detail/changesets/release-note.md +262 -0
- package/zh/guides/topic-detail/changesets/release-pre.md +49 -0
- package/zh/guides/topic-detail/changesets/release.md +228 -0
- package/zh/guides/topic-detail/compile-speed.md +182 -0
- package/zh/guides/topic-detail/framework-plugin/_category_.json +4 -0
- package/zh/guides/topic-detail/framework-plugin/abstract.md +27 -0
- package/zh/guides/topic-detail/framework-plugin/extend.md +163 -0
- package/zh/guides/topic-detail/framework-plugin/implement.md +188 -0
- package/zh/guides/topic-detail/framework-plugin/relationship.md +119 -0
- package/zh/guides/topic-detail/generator-plugin/_category_.json +4 -0
- package/zh/guides/topic-detail/generator-plugin/abstract.md +23 -0
- package/zh/guides/topic-detail/generator-plugin/develop.md +120 -0
- package/zh/guides/topic-detail/generator-plugin/use.md +61 -0
- package/zh/guides/topic-detail/micro-frontend/_category_.json +4 -0
- package/zh/guides/topic-detail/micro-frontend/communicate.md +39 -0
- package/zh/guides/topic-detail/micro-frontend/debugging.md +168 -0
- package/zh/guides/topic-detail/micro-frontend/introduction.md +13 -0
- package/zh/guides/topic-detail/micro-frontend/mixed-stack.md +24 -0
- package/zh/guides/topic-detail/micro-frontend/route-mode.md +110 -0
- package/zh/guides/topic-detail/model/_category_.json +4 -0
- package/zh/guides/topic-detail/model/auto-actions.md +90 -0
- package/zh/guides/topic-detail/model/computed-state.md +151 -0
- package/zh/guides/topic-detail/model/define-model.md +66 -0
- package/zh/guides/topic-detail/model/faq.md +43 -0
- package/zh/guides/topic-detail/model/manage-effects.md +259 -0
- package/zh/guides/topic-detail/model/model-communicate.md +219 -0
- package/zh/guides/topic-detail/model/performance.md +173 -0
- package/zh/guides/topic-detail/model/quick-start.md +112 -0
- package/zh/guides/topic-detail/model/redux-integration.md +21 -0
- package/zh/guides/topic-detail/model/test-model.md +43 -0
- package/zh/guides/topic-detail/model/typescript-best-practice.md +71 -0
- package/zh/guides/topic-detail/model/use-model.md +244 -0
- package/zh/guides/topic-detail/model/use-out-of-modernjs.md +51 -0
- package/zh/guides/topic-detail/monorepo/_category_.json +4 -0
- package/zh/guides/topic-detail/monorepo/create-sub-project.md +64 -0
- package/zh/guides/topic-detail/monorepo/deploy.md +43 -0
- package/zh/guides/topic-detail/monorepo/intro.md +15 -0
- package/zh/guides/topic-detail/monorepo/publish.md +68 -0
- package/zh/guides/topic-detail/monorepo/sub-project-interface.md +170 -0
- package/zh/guides/troubleshooting/_category_.json +5 -0
- package/zh/guides/troubleshooting/compile.md +379 -0
- package/zh/guides/troubleshooting/dependencies.md +168 -0
- package/zh/tutorials/first-app/_category_.json +5 -0
- package/zh/tutorials/first-app/c01-getting-started/1.1-prerequisites.md +25 -0
- package/zh/tutorials/first-app/c01-getting-started/1.2-minimal-mwa.md +118 -0
- package/zh/tutorials/first-app/c01-getting-started/1.3-dev-command.md +29 -0
- package/zh/tutorials/first-app/c01-getting-started/1.4-enable-ssr.md +44 -0
- package/zh/tutorials/first-app/c01-getting-started/1.5-start-command.md +18 -0
- package/zh/tutorials/first-app/c01-getting-started/1.6-create-repo.md +31 -0
- package/zh/tutorials/first-app/c01-getting-started/_category_.json +3 -0
- package/zh/tutorials/first-app/c02-generator-and-studio/2.1-generator.md +87 -0
- package/zh/tutorials/first-app/c02-generator-and-studio/2.2-boilerplates.md +28 -0
- package/zh/tutorials/first-app/c02-generator-and-studio/2.3-configuration.md +21 -0
- package/zh/tutorials/first-app/c02-generator-and-studio/_category_.json +3 -0
- package/zh/tutorials/first-app/c03-ide/3.1-setting-up.md +55 -0
- package/zh/tutorials/first-app/c03-ide/3.2-hints-in-ide.md +66 -0
- package/zh/tutorials/first-app/c03-ide/3.3-autofix-in-ide.md +11 -0
- package/zh/tutorials/first-app/c03-ide/3.4-autofix-in-cli.md +63 -0
- package/zh/tutorials/first-app/c03-ide/_category_.json +3 -0
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.1-use-es6-plus.md +67 -0
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.2-use-typescript.md +111 -0
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/4.3-compatibility.md +67 -0
- package/zh/tutorials/first-app/c04-es6-plus-and-ts/_category_.json +3 -0
- package/zh/tutorials/first-app/c05-component/5.1-use-ui-library.md +68 -0
- package/zh/tutorials/first-app/c05-component/5.2-use-standalone-component.md +92 -0
- package/zh/tutorials/first-app/c05-component/_category_.json +3 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.1-css-in-js.md +110 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.2-utility-class.md +148 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.3-postcss.md +84 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.4-design-system.md +83 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.5-storybook.md +77 -0
- package/zh/tutorials/first-app/c06-css-and-component/6.6-testing.md +113 -0
- package/zh/tutorials/first-app/c06-css-and-component/_category_.json +3 -0
- package/zh/tutorials/first-app/c07-app-entry/7.1-intro.md +64 -0
- package/zh/tutorials/first-app/c07-app-entry/7.2-add-entry-in-cli.md +104 -0
- package/zh/tutorials/first-app/c07-app-entry/7.3-manage-entries-by-hand.md +74 -0
- package/zh/tutorials/first-app/c07-app-entry/_category_.json +3 -0
- package/zh/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing.md +153 -0
- package/zh/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing.md +318 -0
- package/zh/tutorials/first-app/c08-client-side-routing/_category_.json +3 -0
- package/zh/tutorials/first-app/c09-bff/9.1-serverless.md +30 -0
- package/zh/tutorials/first-app/c09-bff/9.2-enable-bff.md +93 -0
- package/zh/tutorials/first-app/c09-bff/9.3-fetch-bff.md +205 -0
- package/zh/tutorials/first-app/c09-bff/_category_.json +3 -0
- package/zh/tutorials/first-app/c10-model/10.1-application-architecture.md +23 -0
- package/zh/tutorials/first-app/c10-model/10.2-add-model.md +185 -0
- package/zh/tutorials/first-app/c10-model/10.3-use-model.md +54 -0
- package/zh/tutorials/first-app/c10-model/10.4-testing.md +69 -0
- package/zh/tutorials/first-app/c10-model/_category_.json +3 -0
- package/zh/tutorials/first-app/c11-container/11.1-use-model-with-app-state.md +274 -0
- package/zh/tutorials/first-app/c11-container/11.2-add-container.md +106 -0
- package/zh/tutorials/first-app/c11-container/11.3-use-loader.md +61 -0
- package/zh/tutorials/first-app/c11-container/11.4-testing.md +56 -0
- package/zh/tutorials/first-app/c11-container/_category_.json +3 -0
- package/zh/tutorials/first-app/overview.md +11 -0
- package/zh/tutorials/foundations/_category_.json +5 -0
- package/zh/tutorials/foundations/basic.md +8 -0
- package/zh/tutorials/foundations/introduction.md +41 -0
@@ -0,0 +1,226 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: ssg
|
3
|
+
---
|
4
|
+
# output.ssg
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
* 类型: `boolean` | `object` | `function`
|
9
|
+
* 默认值: `undefined`
|
10
|
+
|
11
|
+
开启**自控式路由**或**约定式路由** SSG 功能的配置。
|
12
|
+
|
13
|
+
:::info 客户端路由
|
14
|
+
相关内容可以查看[自控式路由](/docs/tutorials/first-app/c08-client-side-routing/8.1-code-based-routing)或[约定式路由](/docs/tutorials/first-app/c08-client-side-routing/8.2-file-based-routing)。
|
15
|
+
:::
|
16
|
+
|
17
|
+
## 示例
|
18
|
+
|
19
|
+
### 单入口
|
20
|
+
|
21
|
+
当该配置设置为 `true` 时,将会默认开启所有入口的 SSG 功能。
|
22
|
+
|
23
|
+
对**自控式路由**而言,将会渲染入口路由。对**约定式路由**而言,将会渲染入口中每一条客户端路由。
|
24
|
+
|
25
|
+
例如 `src/` 目录下有以下满足**约定式路由**的文件结构:
|
26
|
+
|
27
|
+
```bash
|
28
|
+
.
|
29
|
+
├── pages/
|
30
|
+
│ ├── user/
|
31
|
+
│ │ └── info.tsx
|
32
|
+
│ ├── home.tsx
|
33
|
+
│ └── index.tsx
|
34
|
+
├── .eslintrc.json
|
35
|
+
```
|
36
|
+
|
37
|
+
在 `modern.js.config` 中做以下设置:
|
38
|
+
|
39
|
+
```js
|
40
|
+
module.exports = {
|
41
|
+
output: {
|
42
|
+
ssg: true,
|
43
|
+
},
|
44
|
+
};
|
45
|
+
```
|
46
|
+
|
47
|
+
执行 `pnpm build` 构建应用后。`dist/` 目录将会生成三张 HTML 分别对应三条路由(不开启 SSG 时只有一张 HTML 对应主入口),并且可以看到所有 HTML 都已经是渲染之后的。
|
48
|
+
|
49
|
+
而例如下面的**自控式路由**:
|
50
|
+
|
51
|
+
```ts title="App.tsx"
|
52
|
+
import { Switch, Route } from '@modern-js/runtime/router';
|
53
|
+
|
54
|
+
export default () => (
|
55
|
+
<Switch>
|
56
|
+
<Route path="/" exact={true}>
|
57
|
+
<div>Home</div>
|
58
|
+
</Route>
|
59
|
+
<Route path="/foo" exact={true}>
|
60
|
+
<div>Foo</div>
|
61
|
+
</Route>
|
62
|
+
</Switch>
|
63
|
+
);
|
64
|
+
```
|
65
|
+
|
66
|
+
同样使用上面的配置,在执行 `pnpm build` 后,只有入口路由 `/` 会生成渲染后的 HTML。
|
67
|
+
|
68
|
+
### 多入口
|
69
|
+
|
70
|
+
`output.ssg` 也可以按照入口配置,配置生效的规则同样由入口路由方式决定。
|
71
|
+
|
72
|
+
例如以下目录结构:
|
73
|
+
|
74
|
+
```bash
|
75
|
+
.
|
76
|
+
├── src/
|
77
|
+
│ ├── contacts/
|
78
|
+
│ │ └── App.tsx
|
79
|
+
│ ├── landing-page/
|
80
|
+
│ │ └── pages/
|
81
|
+
│ │ ├── [user].tsx
|
82
|
+
│ │ ├── docs.tsx
|
83
|
+
│ │ └── index.tsx
|
84
|
+
```
|
85
|
+
|
86
|
+
默认情况下,所有约定式路由的入口,在设置 `output.ssg` 配置后都会在构建阶段渲染,可以配置 `false` 来取消指定入口的的默认行为,例如取消上述 landing-page 入口在构建时的渲染:
|
87
|
+
|
88
|
+
```js
|
89
|
+
module.exports = {
|
90
|
+
output: {
|
91
|
+
ssg: {
|
92
|
+
contacts: true,
|
93
|
+
'landing-page': false,
|
94
|
+
},
|
95
|
+
},
|
96
|
+
};
|
97
|
+
```
|
98
|
+
|
99
|
+
### 配置路由
|
100
|
+
|
101
|
+
上述内容中提到,**自控式路由**默认只会开启入口路由的 SSG 配置。
|
102
|
+
|
103
|
+
可以在 `output.ssg` 中设置具体的路由,告知 Modern.js 开启这些客户端路由的 SSG 功能。例如上述 `contacts/App.tsx` 的文件内容为:
|
104
|
+
|
105
|
+
```ts title="contacts/App.tsx"
|
106
|
+
import { Switch, Route } from '@modern-js/runtime/router';
|
107
|
+
|
108
|
+
export default () => (
|
109
|
+
<Switch>
|
110
|
+
<Route path="/" exact={true}>
|
111
|
+
<div>Home</div>
|
112
|
+
</Route>
|
113
|
+
<Route path="/foo" exact={true}>
|
114
|
+
<div>Foo</div>
|
115
|
+
</Route>
|
116
|
+
</Switch>
|
117
|
+
);
|
118
|
+
```
|
119
|
+
|
120
|
+
在 `modern.config.js` 中这样设置后,`/foo` 路由也会开启 SSG 功能:
|
121
|
+
|
122
|
+
```js
|
123
|
+
module.exports = {
|
124
|
+
output: {
|
125
|
+
ssg: {
|
126
|
+
contacts: {
|
127
|
+
routes: ['/', '/foo'],
|
128
|
+
},
|
129
|
+
},
|
130
|
+
},
|
131
|
+
};
|
132
|
+
```
|
133
|
+
|
134
|
+
Modern.js 将会自动根据入口拼接完整的 URL 并交给 SSG 插件完成渲染。
|
135
|
+
|
136
|
+
也可以为具体入口或路由配置请求头,例如:
|
137
|
+
|
138
|
+
```js
|
139
|
+
module.exports = {
|
140
|
+
output: {
|
141
|
+
ssg: {
|
142
|
+
contacts: {
|
143
|
+
headers: {},
|
144
|
+
routes: [
|
145
|
+
'/',
|
146
|
+
{
|
147
|
+
url: '/foo',
|
148
|
+
headers: {},
|
149
|
+
},
|
150
|
+
],
|
151
|
+
},
|
152
|
+
},
|
153
|
+
},
|
154
|
+
};
|
155
|
+
```
|
156
|
+
|
157
|
+
:::info
|
158
|
+
路由中设置的 `headers` 会覆盖入口中设置的 `headers`。
|
159
|
+
:::
|
160
|
+
|
161
|
+
### 阻止默认行为
|
162
|
+
|
163
|
+
**约定式路由**也可以通过配置的方式来开启指定路由的 SSG。
|
164
|
+
|
165
|
+
但因为默认行为的不同,这里为**约定式路由**提供了另一个字段,用来阻止默认的 SSG 行为。
|
166
|
+
|
167
|
+
例如以下目录结构,除了 `/docs4` 外的所有 landing-page 入口中的路由都开启 SSG:
|
168
|
+
|
169
|
+
```bash
|
170
|
+
.
|
171
|
+
├── src/
|
172
|
+
│ ├── contacts/
|
173
|
+
│ │ └── App.tsx
|
174
|
+
│ ├── landing-page/
|
175
|
+
│ │ └── pages/
|
176
|
+
│ │ ├── [user].tsx
|
177
|
+
│ │ ├── docs.tsx
|
178
|
+
│ │ ├── docs1.tsx
|
179
|
+
│ │ ├── docs2.tsx
|
180
|
+
│ │ ├── docs3.tsx
|
181
|
+
│ │ ├── docs4.tsx
|
182
|
+
│ │ └── index.tsx
|
183
|
+
```
|
184
|
+
|
185
|
+
可以这样设置,禁用某一条客户端路由的默认行为:
|
186
|
+
|
187
|
+
:::info 注
|
188
|
+
该配置仅在渲染动态路径的约定式路由时使用。
|
189
|
+
:::
|
190
|
+
|
191
|
+
```js
|
192
|
+
module.exports = {
|
193
|
+
output: {
|
194
|
+
'landing-page': {
|
195
|
+
preventDefault: ['/docs4'],
|
196
|
+
},
|
197
|
+
},
|
198
|
+
};
|
199
|
+
```
|
200
|
+
|
201
|
+
### 添加动态路由参数
|
202
|
+
|
203
|
+
部分路由可能是动态的,例如自控式路由中的 `/user/:id` 或是约定式路由中 `user/[id].ts` 文件生成的路由。
|
204
|
+
|
205
|
+
可以在 `output.ssg` 中配置具体的参数,渲染指定参数的路由,例如:
|
206
|
+
|
207
|
+
```js
|
208
|
+
module.exports = {
|
209
|
+
output: {
|
210
|
+
ssg: {
|
211
|
+
'landing-page': {
|
212
|
+
routes: [
|
213
|
+
{
|
214
|
+
url: '/user/:id',
|
215
|
+
params: [
|
216
|
+
{
|
217
|
+
id: 'modernjs',
|
218
|
+
},
|
219
|
+
],
|
220
|
+
},
|
221
|
+
],
|
222
|
+
},
|
223
|
+
},
|
224
|
+
},
|
225
|
+
};
|
226
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: output.svgDefaultExport
|
3
|
+
sidebar_label: svgDefaultExport
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [output.svgDefaultExport](https://modernjs.dev/builder/zh/api/config-output.html#output-svgdefaultexport)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/output/svgDefaultExport.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.buildCache
|
3
|
+
sidebar_label: buildCache
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.buildCache](https://modernjs.dev/builder/zh/api/config-performance.html#performance-buildcache)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/buildCache.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.bundleAnalyze
|
3
|
+
sidebar_label: bundleAnalyze
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.bundleAnalyze](https://modernjs.dev/builder/zh/api/config-performance.html#performance-bundleanalyze)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/bundleAnalyze.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.chunkSplit
|
3
|
+
sidebar_label: chunkSplit
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.chunkSplit](https://modernjs.dev/builder/zh/api/config-performance.html#performance-chunksplit)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/chunkSplit.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.printFileSize
|
3
|
+
sidebar_label: printFileSize
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.printFileSize](https://modernjs.dev/builder/zh/api/config-performance.html#performance-printfilesize)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/printFileSize.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.profile
|
3
|
+
sidebar_label: profile
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.profile](https://modernjs.dev/builder/zh/api/config-performance.html#performance-profile)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/profile.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.removeConsole
|
3
|
+
sidebar_label: removeConsole
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.removeConsole](https://modernjs.dev/builder/zh/api/config-performance.html#performance-removeconsole)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/removeConsole.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: performance.removeMomentLocale
|
3
|
+
sidebar_label: removeMomentLocale
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [performance.removeMomentLocale](https://modernjs.dev/builder/zh/api/config-performance.html#performance-removemomentlocale)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/performance/removeMomentLocale.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,74 @@
|
|
1
|
+
---
|
2
|
+
title: plugins (插件)
|
3
|
+
sidebar_position: 9
|
4
|
+
---
|
5
|
+
|
6
|
+
- 类型: `CliPlugin[] | { cli: CliPlugin[] }`
|
7
|
+
- 默认值:`[]`
|
8
|
+
|
9
|
+
用于配置自定义的 Modern.js 插件。
|
10
|
+
|
11
|
+
自定义插件的编写方式请参考 [如何编写插件](/docs/guides/topic-detail/framework-plugin/implement)。
|
12
|
+
|
13
|
+
该选项用于配置框架插件,如果需要配置 webpack 插件,请使用 [tools.webpack](/docs/configure/app/tools/webpack) 或 [tools.webpackChain](/docs/configure/app/tools/webpack-chain); 需要配置 babel 插件,请使用 [tools.babel](/docs/configure/app/tools/babel)。
|
14
|
+
|
15
|
+
## 插件类型
|
16
|
+
|
17
|
+
Modern.js 中内置了三种不同的插件机制:
|
18
|
+
|
19
|
+
- `CLI 插件`,适用于本地开发、编译构建阶段,可以在命令行和编译阶段扩展各种能力。
|
20
|
+
- `Server 插件`,适用于服务端。
|
21
|
+
- `Runtime 插件`,适用于前端运行时。
|
22
|
+
|
23
|
+
目前 Modern.js 开放了自定义 CLI 插件的能力,Server 插件和 Runtime 插件会在后续开放。
|
24
|
+
|
25
|
+
## 插件执行顺序
|
26
|
+
|
27
|
+
默认情况下,自定义插件会按照 `plugins` 数组的顺序依次执行,Modern.js 内置插件的执行时机早于自定义插件。
|
28
|
+
|
29
|
+
当插件内部使用了控制顺序的相关字段,比如 `pre`、`post` 时,会基于声明的字段对执行顺序进行调整,详见 [插件之间的关系](/docs/guides/topic-detail/framework-plugin/relationship)。
|
30
|
+
|
31
|
+
## 示例
|
32
|
+
|
33
|
+
下面是 CLI 插件的使用示例。
|
34
|
+
|
35
|
+
### 使用 npm 上的插件
|
36
|
+
|
37
|
+
使用 npm 上的插件,需要通过包管理器安装插件,并通过 import 引入。
|
38
|
+
|
39
|
+
```ts title="modern.config.ts"
|
40
|
+
import MyPlugin from 'my-plugin';
|
41
|
+
|
42
|
+
export default defineConfig({
|
43
|
+
plugins: [MyPlugin()],
|
44
|
+
});
|
45
|
+
```
|
46
|
+
|
47
|
+
### 使用本地插件
|
48
|
+
|
49
|
+
使用本地代码仓库中的插件,直接通过相对路径 import 引入即可。
|
50
|
+
|
51
|
+
```ts title="modern.config.ts"
|
52
|
+
import MyPlugin from './config/plugin/MyPlugin';
|
53
|
+
|
54
|
+
export default defineConfig({
|
55
|
+
plugins: [MyPlugin()],
|
56
|
+
});
|
57
|
+
```
|
58
|
+
|
59
|
+
### 插件配置项
|
60
|
+
|
61
|
+
如果插件提供了一些自定义的配置项,可以通过插件函数的参数传入配置。
|
62
|
+
|
63
|
+
```ts title="modern.config.ts"
|
64
|
+
import MyPlugin from 'my-plugin';
|
65
|
+
|
66
|
+
export default defineConfig({
|
67
|
+
plugins: [
|
68
|
+
MyPlugin({
|
69
|
+
foo: 1,
|
70
|
+
bar: 2,
|
71
|
+
}),
|
72
|
+
],
|
73
|
+
});
|
74
|
+
```
|
@@ -0,0 +1,72 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: masterApp
|
3
|
+
sidebar_position: 3
|
4
|
+
---
|
5
|
+
|
6
|
+
# runtime.masterApp
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
* 类型: `Object`
|
11
|
+
|
12
|
+
:::tip 提示
|
13
|
+
```ts
|
14
|
+
export declare type Config = Partial<GarfishOptions> & {
|
15
|
+
manifest: {
|
16
|
+
modules: Array<{
|
17
|
+
name: string;
|
18
|
+
entry: string;
|
19
|
+
activeWhen?: string;
|
20
|
+
}> | string;
|
21
|
+
};
|
22
|
+
LoadingComponent?: React.ComponentType | React.ElementType;
|
23
|
+
};
|
24
|
+
```
|
25
|
+
:::
|
26
|
+
|
27
|
+
## `manifest`
|
28
|
+
|
29
|
+
- 类型:`modules: Array<{
|
30
|
+
name: string;
|
31
|
+
entry: string;
|
32
|
+
activeWhen?: string;
|
33
|
+
}> | string;`
|
34
|
+
- 默认值:`null`
|
35
|
+
|
36
|
+
### `modules`
|
37
|
+
|
38
|
+
当 `modules` 为对象类型的时候,表示子应用模块的信息。
|
39
|
+
|
40
|
+
- name: 子应用的名称。
|
41
|
+
- entry: 子应用的入口。
|
42
|
+
- activeWhen?: 子应用激活路径。
|
43
|
+
|
44
|
+
当 `modules` 为 `string` 时,是一个 url 地址,请求该地址可以拿到和 `modules` 对象格式一样的数据结构。
|
45
|
+
|
46
|
+
## `LoadingComponent`
|
47
|
+
|
48
|
+
- 类型: `React.ComponentType | React.ElementType`
|
49
|
+
- 默认值 `null`
|
50
|
+
|
51
|
+
当加载或切换子应用的时候,加载的过渡动画。
|
52
|
+
|
53
|
+
`LoadingComponent` 需要通过 [defineConfig](/docs/apis/app/runtime/app/define-config) 配置。
|
54
|
+
|
55
|
+
```tsx
|
56
|
+
import { defineConfig } from '@modern-js/runtime';
|
57
|
+
|
58
|
+
function App() {
|
59
|
+
...
|
60
|
+
}
|
61
|
+
|
62
|
+
defineConfig(
|
63
|
+
App,
|
64
|
+
{
|
65
|
+
masterApp: {
|
66
|
+
LoadingComponent: () => {
|
67
|
+
return <div>loading...</div>
|
68
|
+
}
|
69
|
+
}
|
70
|
+
}
|
71
|
+
)
|
72
|
+
```
|
@@ -0,0 +1,54 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: router
|
3
|
+
sidebar_position: 1
|
4
|
+
---
|
5
|
+
|
6
|
+
# runtime.router
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
* 类型: `Object`
|
11
|
+
* 默认值: 默认会根据当前入口访问路由设置 `historyOptions.basename`。
|
12
|
+
|
13
|
+
:::tip 提示
|
14
|
+
|
15
|
+
```ts
|
16
|
+
export interface BrowserHistoryBuildOptions {
|
17
|
+
basename?: string | undefined;
|
18
|
+
forceRefresh?: boolean | undefined;
|
19
|
+
getUserConfirmation?: typeof getConfirmation | undefined;
|
20
|
+
keyLength?: number | undefined;
|
21
|
+
}
|
22
|
+
|
23
|
+
export interface HashHistoryBuildOptions {
|
24
|
+
basename?: string | undefined;
|
25
|
+
hashType?: HashType | undefined;
|
26
|
+
getUserConfirmation?: typeof getConfirmation | undefined;
|
27
|
+
}
|
28
|
+
|
29
|
+
export type RouterConfig = {
|
30
|
+
supportHtml5History: true;
|
31
|
+
historyOptions: BrowserHistoryBuildOptions;
|
32
|
+
}
|
33
|
+
| {
|
34
|
+
supportHtml5History: false;
|
35
|
+
historyOptions: HashHistoryBuildOptions;
|
36
|
+
}
|
37
|
+
```
|
38
|
+
:::
|
39
|
+
|
40
|
+
具体配置选项解释如下:
|
41
|
+
|
42
|
+
### supportHtml5History
|
43
|
+
|
44
|
+
* 类型: `Boolean`
|
45
|
+
* 默认值: `true`
|
46
|
+
|
47
|
+
值为 `true` 则使用 `BrowserRouter` 否则使用 `HashRouter`。
|
48
|
+
|
49
|
+
### historyOptions
|
50
|
+
|
51
|
+
* 类型: `BrowserHistoryBuildOptions | HashHistoryBuildOptions`
|
52
|
+
* 默认值: 默认会根据当前入口路由设置 basename。
|
53
|
+
|
54
|
+
historyOptions 具体配置可以参考: [history](https://github.com/remix-run/history/blob/v4/docs/Misc.md)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: state
|
3
|
+
sidebar_position: 2
|
4
|
+
---
|
5
|
+
|
6
|
+
# runtime.state
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
- 类型:`boolean | object`
|
11
|
+
- 默认值:`false`
|
12
|
+
|
13
|
+
开启 `state` 后就可以使用 [Model](/docs/guides/topic-detail/model/quick-start) 来做状态管理。
|
14
|
+
|
15
|
+
|
16
|
+
具体配置项如下:
|
17
|
+
|
18
|
+
## `immer`
|
19
|
+
|
20
|
+
- 类型:`boolean`
|
21
|
+
- 默认值:`true`
|
22
|
+
|
23
|
+
是否启用以 mutable 更新 state 的方式,默认启用,若想禁用则设置为 `false`。
|
24
|
+
|
25
|
+
## `effects`
|
26
|
+
|
27
|
+
- 类型:`boolean`
|
28
|
+
- 默认值:`true`
|
29
|
+
|
30
|
+
是否启用副作用管理特性,默认启用,若想禁用则设置为 `false`。
|
31
|
+
|
32
|
+
## `autoActions`
|
33
|
+
|
34
|
+
- 类型:`boolean`
|
35
|
+
- 默认值:`true`
|
36
|
+
|
37
|
+
是否启用自动生成 actions 特性,默认启用,若想禁用则设置为 `false`。
|
38
|
+
|
39
|
+
|
40
|
+
## `devtools`
|
41
|
+
|
42
|
+
- 类型:`boolean | EnhancerOptions`
|
43
|
+
- 默认值:`true`
|
44
|
+
|
45
|
+
是否启用 devtools,默认启用,同时支持 [redux-devtools-extension](https://github.com/zalmoxisus/redux-devtools-extension/blob/master/docs/API/Arguments.md) 的所有参数,若想禁用则设置为 `false`。
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: security.sri
|
3
|
+
sidebar_label: sri
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [security.sri](https://modernjs.dev/builder/zh/api/config-security.html#security-sri)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/security/sri.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,36 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: baseUrl
|
3
|
+
sidebar_position: 3
|
4
|
+
---
|
5
|
+
|
6
|
+
# server.baseUrl
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
* 类型: `string | string[]`
|
11
|
+
* 默认值: `undefined`
|
12
|
+
|
13
|
+
|
14
|
+
统一设置服务端路由前缀(常用于共享域名的情况,区分流量)。
|
15
|
+
|
16
|
+
```js title="modern.config.js"
|
17
|
+
export default defineConfig({
|
18
|
+
server: {
|
19
|
+
// 所有生成的路由前面都会自动加上前缀 `/base`
|
20
|
+
// 生成的服务端路由文件路径:dist/route.json
|
21
|
+
baseUrl: '/base'
|
22
|
+
|
23
|
+
// 多 baseUrl
|
24
|
+
baseUrl: ['/base-new', '/base-old']
|
25
|
+
}
|
26
|
+
})
|
27
|
+
```
|
28
|
+
|
29
|
+
`dev` 之后可以看到路由访问会加上对应前缀:
|
30
|
+
|
31
|
+
```bash
|
32
|
+
App running at:
|
33
|
+
|
34
|
+
> Local: http://localhost:8080/base/
|
35
|
+
> Network: http://192.168.0.1:8080/base/
|
36
|
+
```
|
@@ -0,0 +1,21 @@
|
|
1
|
+
---
|
2
|
+
sidebar_label: port
|
3
|
+
sidebar_position: 5
|
4
|
+
---
|
5
|
+
|
6
|
+
# server.port
|
7
|
+
|
8
|
+
|
9
|
+
|
10
|
+
* 类型: `Number`
|
11
|
+
* 默认值: `8080`
|
12
|
+
|
13
|
+
Modern.js 在 `dev` 和 `start` 时会以 `8080` 为默认端口启动,通过该配置可以修改 Server 启动的端口号:
|
14
|
+
|
15
|
+
```js title="modern.config.js"
|
16
|
+
export default defineConfig({
|
17
|
+
server: {
|
18
|
+
port: 3000,
|
19
|
+
}
|
20
|
+
});
|
21
|
+
```
|