@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,23 @@
|
|
1
|
+
---
|
2
|
+
title: source.disableDefaultEntries
|
3
|
+
sidebar_label: disableDefaultEntries
|
4
|
+
---
|
5
|
+
|
6
|
+
- 类型: `boolean`
|
7
|
+
- 默认值: `false`
|
8
|
+
|
9
|
+
关闭根据项目目录结构自动识别应用构建入口的功能,默认情况下,Modern.js 会根据项目目录结构得到对应构建入口。
|
10
|
+
|
11
|
+
:::warning 警告
|
12
|
+
推荐按照 Modern.js 提供的目录规范组织代码可以更好使用框架的功能,避免一些冗余的配置。
|
13
|
+
:::
|
14
|
+
|
15
|
+
设置如下,即可关闭默认的行为:
|
16
|
+
|
17
|
+
```js title="modern.config.js"
|
18
|
+
export default defineConfig({
|
19
|
+
source: {
|
20
|
+
disableDefaultEntries: true,
|
21
|
+
},
|
22
|
+
});
|
23
|
+
```
|
@@ -0,0 +1,53 @@
|
|
1
|
+
---
|
2
|
+
title: source.enableAsyncEntry
|
3
|
+
sidebar_label: enableAsyncEntry
|
4
|
+
---
|
5
|
+
|
6
|
+
- 类型: `boolean`
|
7
|
+
- 默认值: `false`
|
8
|
+
|
9
|
+
该选项用于 webpack 模块联邦 (Module Federation)场景。
|
10
|
+
|
11
|
+
开启此选项后,Modern.js 会通过 Dynamic Import 来包裹自动生成的入口文件(asynchronous boundary),使页面代码可以消费模块联邦生成的远程模块。
|
12
|
+
|
13
|
+
## 背景知识
|
14
|
+
|
15
|
+
如果不了解 webpack 模块联邦,请先阅读 Module Federation 官方文档:
|
16
|
+
|
17
|
+
- [中文文档](https://webpack.docschina.org/concepts/module-federation/)
|
18
|
+
- [英文文档](https://webpack.js.org/concepts/module-federation)
|
19
|
+
|
20
|
+
## 示例
|
21
|
+
|
22
|
+
首先,在配置文件中开启此选项:
|
23
|
+
|
24
|
+
```js title="modern.config.js"
|
25
|
+
export default defineConfig({
|
26
|
+
source: {
|
27
|
+
enableAsyncEntry: true,
|
28
|
+
},
|
29
|
+
});
|
30
|
+
```
|
31
|
+
|
32
|
+
然后执行 `dev` 或 `build` 命令,可以看到 Modern.js 自动生成的文件变为以下结构:
|
33
|
+
|
34
|
+
```bash
|
35
|
+
node_modules
|
36
|
+
└─ .modern-js
|
37
|
+
└─ main
|
38
|
+
├─ bootstrap.js # 真正的入口代码
|
39
|
+
├─ index.js # 异步入口文件(asynchronous boundary)
|
40
|
+
└─ index.html
|
41
|
+
```
|
42
|
+
|
43
|
+
其中 `index.js` 的内容如下:
|
44
|
+
|
45
|
+
```js
|
46
|
+
import('./bootstrap.js');
|
47
|
+
```
|
48
|
+
|
49
|
+
此时,就可以在当前页面中消费任意的远程模块了。
|
50
|
+
|
51
|
+
:::info
|
52
|
+
Modern.js 未对 webpack 的 ModuleFederationPlugin 进行封装,请通过 [tools.webpackChain](/docs/configure/app/tools/webpack-chain) 自行配置 ModuleFederationPlugin。
|
53
|
+
:::
|
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
title: source.entriesDir
|
3
|
+
|
4
|
+
sidebar_label: entriesDir
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
* 类型: `string`
|
10
|
+
* 默认值: `./src`
|
11
|
+
|
12
|
+
|
13
|
+
默认会根据 `src` 目录识别应用入口,可通过该选项自定义应用入口的识别目录。
|
14
|
+
|
15
|
+
例如,当配置与目录结构如下时:
|
16
|
+
|
17
|
+
```js title="modern.config.js"
|
18
|
+
export default defineConfig({
|
19
|
+
source: {
|
20
|
+
entriesDir: './src/pages'
|
21
|
+
}
|
22
|
+
})
|
23
|
+
```
|
24
|
+
|
25
|
+
``` title="项目目录结构"
|
26
|
+
.
|
27
|
+
└── src
|
28
|
+
└── pages
|
29
|
+
├── a
|
30
|
+
│ └── App.jsx
|
31
|
+
└── b
|
32
|
+
└── App.jsx
|
33
|
+
```
|
34
|
+
|
35
|
+
Modern.js 会根据 `./src/pages` 目录结构生成构建入口 `a` 和入口 `b`,结果如下:
|
36
|
+
|
37
|
+
```js
|
38
|
+
{
|
39
|
+
a: './src/pages/a/App.jsx',
|
40
|
+
b: './src/pages/b/App.jsx'
|
41
|
+
}
|
42
|
+
```
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
title: source.entries
|
3
|
+
sidebar_label: entries
|
4
|
+
---
|
5
|
+
|
6
|
+
|
7
|
+
|
8
|
+
* 类型: `Object = { [ entryName: string ]: string | Object }`
|
9
|
+
* 默认值: 根据当前项目目录结构动态结算出的默认入口对象。
|
10
|
+
|
11
|
+
对于大部分场景,Modern.js 根据目录结构自动生成的入口能满足大部分业务需求。
|
12
|
+
|
13
|
+
如需自定义构建入口时,可以通过该选项指定。例如,当值为 `string` 时,指向入口的文件路径:
|
14
|
+
|
15
|
+
```js title="modern.config.js"
|
16
|
+
export default defineConfig({
|
17
|
+
source: {
|
18
|
+
entries: {
|
19
|
+
// 指定一个名称为 entry_customize 的新入口
|
20
|
+
entry_customize: './src/home/test/index.js',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
});
|
24
|
+
```
|
25
|
+
|
26
|
+
自定义的入口,只需要导出 `App` 组件,Modern.js 会生成真正的入口文件。
|
27
|
+
|
28
|
+
需要关闭这一行为时,可以将值设为 `Object`,属性 `disableMount` 设置为 `true`。
|
29
|
+
|
30
|
+
|
31
|
+
当值为 `Object` 时,可配置如下属性:
|
32
|
+
|
33
|
+
* `entry`:`string`,入口文件路径。
|
34
|
+
* `disableMount`:`boolean = false`,关闭 Modern.js 生成入口代码的行为。
|
35
|
+
* `enableFileSystemRoutes`:`boolean = false`,是否 [使用约定式路由](/docs/apis/app/hooks/src/pages)。
|
36
|
+
|
37
|
+
```js
|
38
|
+
export default defineConfig({
|
39
|
+
source: {
|
40
|
+
entries: {
|
41
|
+
entry_customize: {
|
42
|
+
// 入口文件路径
|
43
|
+
entry: './src/home/test/App.jsx',
|
44
|
+
},
|
45
|
+
// 启用约定式路由
|
46
|
+
entry_spa: {
|
47
|
+
// 约定式路由的入口路径必须设置为目录
|
48
|
+
entry: './src/about',
|
49
|
+
enableFileSystemRoutes: true,
|
50
|
+
},
|
51
|
+
},
|
52
|
+
},
|
53
|
+
};
|
54
|
+
```
|
55
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.globalVars
|
3
|
+
sidebar_label: globalVars
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.globalVars](https://modernjs.dev/builder/zh/api/config-source.html#source-globalvars)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/globalVars.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.include
|
3
|
+
sidebar_label: include
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.include](https://modernjs.dev/builder/zh/api/config-source.html#source-include)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/include.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.moduleScopes
|
3
|
+
sidebar_label: moduleScopes
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.moduleScopes](https://modernjs.dev/builder/zh/api/config-source.html#source-modulescopes)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/moduleScopes.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.preEntry
|
3
|
+
sidebar_label: preEntry
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.preEntry](https://modernjs.dev/builder/zh/api/config-source.html#source-preentry)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/preEntry.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.resolveExtensionPrefix
|
3
|
+
sidebar_label: resolveExtensionPrefix
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.resolveExtensionPrefix](https://modernjs.dev/builder/zh/api/config-source.html#source-resolveextensionprefix)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/resolveExtensionPrefix.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: source.resolveMainFields
|
3
|
+
sidebar_label: resolveMainFields
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [source.resolveMainFields](https://modernjs.dev/builder/zh/api/config-source.html#source-resolvemainfields)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/source/resolveMainFields.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,17 @@
|
|
1
|
+
---
|
2
|
+
title: testing.transformer
|
3
|
+
sidebar_label: transformer
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
- 类型:`'babel-jest' | 'ts-jest'`
|
10
|
+
- 默认值:`babel-jest`
|
11
|
+
|
12
|
+
配置执行测试的时候对于源码的编译工具: [babel-jest](https://www.npmjs.com/package/babel-jest) 或 [ts-jest](https://github.com/kulshekhar/ts-jest)。默认使用 `babel-jest`。
|
13
|
+
|
14
|
+
:::info 补充信息
|
15
|
+
`babel-jest` 也可以编译 TS 文件,但不会类型报错,如果你需要跑测试的时候对 TS 类型进行校验,那么请使用 `ts-jest`。
|
16
|
+
:::
|
17
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.autoprefixer
|
3
|
+
sidebar_label: autoprefixer
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.autoprefixer](https://modernjs.dev/builder/zh/api/config-tools.html#tools-autoprefixer)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/autoprefixer.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.babel
|
3
|
+
sidebar_label: babel
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.babel](https://modernjs.dev/builder/zh/api/config-tools.html#tools-babel)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/babel.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.cssExtract
|
3
|
+
sidebar_label: cssExtract
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.cssExtract](https://modernjs.dev/builder/zh/api/config-tools.html#tools-cssextract)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/cssExtract.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.cssLoader
|
3
|
+
sidebar_label: cssLoader
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.cssLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-cssloader)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/cssLoader.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.devServer
|
3
|
+
sidebar_label: devServer
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.devServer](https://modernjs.dev/builder/zh/api/config-tools.html#tools-devserver)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/devServer.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,61 @@
|
|
1
|
+
---
|
2
|
+
title: tools.esbuild
|
3
|
+
sidebar_label: esbuild
|
4
|
+
---
|
5
|
+
|
6
|
+
- 类型: `Object`
|
7
|
+
- 默认值: `undefined`
|
8
|
+
|
9
|
+
## 介绍
|
10
|
+
|
11
|
+
esbuild 是使用 Go 语言编写的 JavaScript Bundler/Minifier,它的特点是速度极快。在代码压缩方面,相比 webpack 内置的 terser 压缩器,esbuild 在性能上有数十倍的提升。
|
12
|
+
|
13
|
+
Modern.js 基于 esbuild 提供了代码编译和压缩的能力,在大型工程中开启后,**可以大幅度减少代码压缩所需的时间,同时有效避免 OOM (heap out of memory) 问题**。
|
14
|
+
|
15
|
+
使用 esbuild 压缩虽然带来了构建效率上的提升,但 esbuild 的压缩比例是低于 terser 的,因此**构建产物的体积会增大**,请根据业务情况酌情使用(比较适合中后台场景)。
|
16
|
+
|
17
|
+
对于压缩工具之间的详细对比,可以参考 [minification-benchmarks](https://github.com/privatenumber/minification-benchmarks)。
|
18
|
+
|
19
|
+
:::info
|
20
|
+
除了代码压缩外,esbuild 也可以代替 babel 进行代码编译,优点是可以提升编译速度,缺点是无法使用丰富的 babel 插件能力。
|
21
|
+
:::
|
22
|
+
|
23
|
+
## 配置项
|
24
|
+
|
25
|
+
### target
|
26
|
+
|
27
|
+
- 类型: `string | string[]`
|
28
|
+
- 默认值: `'esnext'`
|
29
|
+
|
30
|
+
为生成的 JavaScript 和 CSS 代码设置目标环境。
|
31
|
+
|
32
|
+
可以直接设置为 JavaScript 语言版本,比如 `es5`,`es6`,`es2020`。也可以设置为若干个目标环境,每个目标环境都是一个环境名称后跟一个版本号。比如 `['chrome58', 'edge16' ,'firefox57']`。
|
33
|
+
|
34
|
+
支持设置以下环境:
|
35
|
+
|
36
|
+
- chrome
|
37
|
+
- edge
|
38
|
+
- firefox
|
39
|
+
- ie
|
40
|
+
- ios
|
41
|
+
- node
|
42
|
+
- opera
|
43
|
+
- safari
|
44
|
+
|
45
|
+
默认情况下,esbuild 压缩过程中会引入 ES6 代码,比如模板字符串。如果需要兼容 ES5,可以将 `target` 设置为 `es5`。
|
46
|
+
|
47
|
+
```js title="modern.config.js"
|
48
|
+
export default defineConfig({
|
49
|
+
tools: {
|
50
|
+
esbuild: {
|
51
|
+
target: 'es5',
|
52
|
+
},
|
53
|
+
},
|
54
|
+
});
|
55
|
+
```
|
56
|
+
|
57
|
+
:::info
|
58
|
+
设置 `target` 为 `es5` 时,需要保证所有代码被 babel 转义为 es5 代码,否则会导致 esbuild 编译报错:`Transforming 'xxx' to the configured target environment ("es5") is not supported yet`。
|
59
|
+
|
60
|
+
`target` 字段的详细介绍可以参考 [esbuild - target](https://esbuild.github.io/api/#target)。
|
61
|
+
:::
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.htmlPlugin
|
3
|
+
sidebar_label: htmlPlugin
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.htmlPlugin](https://modernjs.dev/builder/zh/api/config-tools.html#tools-htmlplugin)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/htmlPlugin.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.inspector
|
3
|
+
sidebar_label: inspector
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.inspector](https://modernjs.dev/builder/zh/api/config-tools.html#tools-inspector)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/inspector.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
title: tools.jest
|
3
|
+
|
4
|
+
sidebar_label: jest
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
|
9
|
+
:::caution 注意
|
10
|
+
需要先通过 `pnpm run new` 启用 单元测试 功能。
|
11
|
+
:::
|
12
|
+
|
13
|
+
* 类型: `Object | Function`
|
14
|
+
* 默认值:`{}`
|
15
|
+
|
16
|
+
对应 [Jest](https://jestjs.io/docs/configuration) 的配置,当为 `Object` 类型时,可以配置 Jest 所支持的所有底层配置 。
|
17
|
+
|
18
|
+
```js title=modern.config.js
|
19
|
+
export default defineConfig({
|
20
|
+
tools: {
|
21
|
+
jest: {
|
22
|
+
testTimeout: 10000
|
23
|
+
}
|
24
|
+
}
|
25
|
+
});
|
26
|
+
```
|
27
|
+
|
28
|
+
值为 `Function` 类型时,默认配置作为第一个参数传入,需要返回新的 Jest 配置对象。
|
29
|
+
|
30
|
+
```js title=modern.config.js
|
31
|
+
export default defineConfig({
|
32
|
+
tools: {
|
33
|
+
jest: options => {
|
34
|
+
return {
|
35
|
+
...options,
|
36
|
+
testTimeout: 10000
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
});
|
41
|
+
```
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.less
|
3
|
+
sidebar_label: less
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.less](https://modernjs.dev/builder/zh/api/config-tools.html#tools-less)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/less.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.minifyCss
|
3
|
+
sidebar_label: minifyCss
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.minifyCss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-minifycss)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/minifyCss.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.postcss
|
3
|
+
sidebar_label: postcss
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.postcss](https://modernjs.dev/builder/zh/api/config-tools.html#tools-postcss)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/postcss.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.pug
|
3
|
+
sidebar_label: pug
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.pug](https://modernjs.dev/builder/zh/api/config-tools.html#tools-pug)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/pug.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.sass
|
3
|
+
sidebar_label: sass
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.sass](https://modernjs.dev/builder/zh/api/config-tools.html#tools-sass)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/sass.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.styleLoader
|
3
|
+
sidebar_label: styleLoader
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.styleLoader](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styleloader)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/styleLoader.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.styledComponents
|
3
|
+
sidebar_label: styledComponents
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.styledComponents](https://modernjs.dev/builder/zh/api/config-tools.html#tools-styledcomponents)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/styledComponents.md'
|
12
|
+
|
13
|
+
<Main />
|
@@ -0,0 +1,48 @@
|
|
1
|
+
---
|
2
|
+
title: tools.tailwindcss
|
3
|
+
|
4
|
+
sidebar_label: tailwindcss
|
5
|
+
---
|
6
|
+
|
7
|
+
|
8
|
+
* 类型: `Object | Function`
|
9
|
+
* 默认值:见下方配置详情。
|
10
|
+
|
11
|
+
<details>
|
12
|
+
<summary>TailwindCSS 配置详情</summary>
|
13
|
+
|
14
|
+
```js
|
15
|
+
const tailwind = {
|
16
|
+
purge: {
|
17
|
+
enabled: options.env === 'production',
|
18
|
+
content: [
|
19
|
+
'./config/html/**/*.html',
|
20
|
+
'./config/html/**/*.ejs',
|
21
|
+
'./config/html/**/*.hbs',
|
22
|
+
'./src/**/*',
|
23
|
+
],
|
24
|
+
layers: ['utilities'],
|
25
|
+
},
|
26
|
+
// https://tailwindcss.com/docs/upcoming-changes
|
27
|
+
future: {
|
28
|
+
removeDeprecatedGapUtilities: false,
|
29
|
+
purgeLayersByDefault: true,
|
30
|
+
defaultLineHeights: false,
|
31
|
+
standardFontWeights: false,
|
32
|
+
},
|
33
|
+
theme: source.designSystem // 使用source.designSystem配置作为Tailwind CSS Theme配置
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
:::tip 提示
|
38
|
+
更多关于:<a href="https://tailwindcss.com/docs/configuration" target="_blank">TailwindCSS 配置</a>。
|
39
|
+
:::
|
40
|
+
</details>
|
41
|
+
|
42
|
+
对应 [TailwindCSS](https://tailwindcss.com/docs/configuration) 的配置,值为 `Object` 类型时,与默认配置通过 `Object.assign` 合并。
|
43
|
+
|
44
|
+
值为 `Function` 类型时,函数返回的对象与默认配置通过 `Object.assign` 合并。
|
45
|
+
|
46
|
+
不允许出现 `theme` 属性,否则会构建失败。 Modern.js 使用 [`source.designSystem`](/docs/configure/app/source/design-system) 作为 `Tailwind CSS Theme` 配置。
|
47
|
+
|
48
|
+
其他的使用方式和 Tailwind CSS 一致: [快速传送门](https://tailwindcss.com/docs/configuration)。
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
title: tools.terser
|
3
|
+
sidebar_label: terser
|
4
|
+
sidebar_position: 1
|
5
|
+
---
|
6
|
+
|
7
|
+
:::info BUILDER
|
8
|
+
该配置为 Modern.js Builder 配置,可能存在无法跳转的链接。详细信息可参考 [tools.terser](https://modernjs.dev/builder/zh/api/config-tools.html#tools-terser)。
|
9
|
+
:::
|
10
|
+
|
11
|
+
import Main from '@modern-js/builder-doc/zh/config/tools/terser.md'
|
12
|
+
|
13
|
+
<Main />
|