@modern-js/main-doc 2.0.3-alpha.0 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/lint.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/commands/serve.md +2 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/framework/lambda.md +12 -12
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/api.md +13 -13
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/app.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/api/functions/common.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/app.md +16 -9
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/index_.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/routes.md +5 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/server.md +6 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/stories.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/hooks/src/test.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/app/define-config.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/bff/hook.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/bootstrap.md +3 -6
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/create-app.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-module-apps.md +58 -51
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/core/use-runtime-context.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/connect.md +8 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/create-store.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/handle-effect.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/model_.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-model.md +0 -3
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/model/use-store.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/router/router.md +23 -54
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/no-ssr.md +1 -8
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/ssr/pre-render.md +10 -6
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/testing/render.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/css-in-js.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/head.md +3 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/utility/loadable.md +14 -15
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/hook.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/apis/app/runtime/web-server/middleware.md +7 -6
- package/en/docusaurus-plugin-content-docs/current/components/command-tip.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/components/enable-bff.md +12 -16
- package/en/docusaurus-plugin-content-docs/current/components/enable-micro-frontend.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/components/global-proxy-config.md +6 -9
- package/en/docusaurus-plugin-content-docs/current/components/global-proxy.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/components/micro-master-manifest-config.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/components/micro-runtime-config.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/components/reduck-migration.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/components/reduck-tip.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/components/router-legacy-tip.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/auto-load-plugin.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/prefix.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/bff/proxy.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/builder-plugins.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/deploy/microFrontend.md +11 -13
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/asset-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/hmr.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/https.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/port.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/progress-bar.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/proxy.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/dev/start-url.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/experiments/lazy-compilation.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/app-icon.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/crossorigin.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/disable-html-folder.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/favicon.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/inject.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/meta.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/mount-id.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/tags-by-entries.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/tags.md +12 -0
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template-parameters.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/template.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title-by-entries.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/html/title.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/asset-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/assets-retry.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/charset.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/clean-dist-path.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/convert-to-rem.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/copy.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/css-module-local-ident-name.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/data-uri-limit.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-extract.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-css-module-extension.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-filename-hash.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-inline-runtime-chunk.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-minimize.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-node-polyfill.md +8 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-source-map.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/disable-ts-checker.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/dist-path.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-fallback.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-asset-manifest.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-css-module-tsdeclaration.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-scripts.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-inline-styles.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/enable-latest-decorators.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/externals.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/filename.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/legal-comments.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/override-browserslist.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/polyfill.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/ssg.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/output/svg-default-export.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/build-cache.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/bundle-analyze.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/chunk-split.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/print-file-size.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/profile.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-console.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/performance/remove-moment-locale.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/plugins.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/intro.md +11 -10
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/master-app.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/router.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/runtime/state.md +15 -15
- package/en/docusaurus-plugin-content-docs/current/configure/app/security/sri.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/base-url.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/enable-framework-ext.md +5 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/port.md +24 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/public-routes.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/routes.md +7 -7
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr-by-entries.md +5 -5
- package/en/docusaurus-plugin-content-docs/current/configure/app/server/ssr.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/alias.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/compile-js-data-uri.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/config-dir.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/define.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/design-system.md +656 -634
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-default-entries.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/disable-entry-dirs.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/enable-async-entry.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries-dir.md +7 -7
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/entries.md +4 -6
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/exclude.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/global-vars.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/include.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/module-scopes.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/pre-entry.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-extension-prefix.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/source/resolve-main-fields.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/autoprefixer.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/babel.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-extract.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/css-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/dev-server.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/html-plugin.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/inspector.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/jest.md +9 -9
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/less.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/minify-css.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/postcss.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/pug.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/sass.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/style-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/styled-components.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/swc.md +12 -1
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/terser.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-checker.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/ts-loader.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack-chain.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/configure/app/tools/webpack.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/frameworks.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/function.md +44 -38
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/index.md +9 -9
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/bff/type.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/code-split.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/compatibility.md +6 -7
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/eslint.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/index.md +0 -5
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/low-level.md +17 -19
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssg.md +8 -10
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/ssr.md +5 -11
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/testing.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/advanced-features/web-server.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/alias.md +7 -11
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-in-js.md +6 -6
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/css-modules.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/less-sass.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/postcss.md +43 -47
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/css/tailwindcss.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/data-fetch.md +106 -192
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/env-vars.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/html.md +55 -47
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/mock.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/proxy.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/basic-features/routes.md +90 -9
- package/en/docusaurus-plugin-content-docs/current/guides/concept/entries.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/quick-start.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/get-started/upgrade.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/extend.md +13 -13
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook-list.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/hook.md +57 -54
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/implement.md +11 -11
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/lifecycle.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/framework-plugin/plugin-api.md +4 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/app.md +33 -33
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/ejs.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/fs.md +3 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/git.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/handlebars.md +3 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/json.md +9 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/api/npm.md +2 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/introduce.md +4 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/run-in-js.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/codesmith/structure.md +13 -11
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/config/common.md +18 -27
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/abstract.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +4 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/hook/onForged.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +1 -3
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/setInput.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/api/introduce.md +8 -9
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/develop.md +11 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/plugin/use.md +8 -8
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/generator/project.md +1 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c01-introduction.md +7 -8
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c02-development.md +18 -21
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c03-main-app.md +41 -44
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c04-communicate.md +7 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/micro-frontend/c05-mixed-stack.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/auto-actions.md +0 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/computed-state.md +0 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/define-model.md +3 -6
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/faq.md +2 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/manage-effects.md +2 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/model-communicate.md +1 -4
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/performance.md +1 -5
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/quick-start.md +0 -6
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/redux-integration.md +3 -2
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/test-model.md +1 -1
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/typescript-best-practice.md +13 -14
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-model.md +14 -12
- package/en/docusaurus-plugin-content-docs/current/guides/topic-detail/model/use-out-of-modernjs.md +4 -6
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c01-start.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c03-css.md +6 -8
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c04-routes.md +2 -2
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c05-loader.md +2 -1
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c07-container.md +5 -5
- package/en/docusaurus-plugin-content-docs/current/tutorials/first-app/c08-entries.md +5 -6
- package/package.json +4 -4
- package/scripts/config.ts +4 -2
- package/scripts/summary.en.json +1 -1
- package/scripts/summary.zh.json +1 -1
- package/scripts/sync.ts +1 -1
- package/zh/apis/app/commands/index.md +0 -5
- package/zh/apis/app/commands/lint.md +1 -1
- package/zh/apis/app/commands/serve.md +2 -4
- package/zh/apis/app/hooks/api/framework/lambda.md +12 -12
- package/zh/apis/app/hooks/api/functions/api.md +13 -13
- package/zh/apis/app/hooks/api/functions/app.md +0 -2
- package/zh/apis/app/hooks/api/functions/common.md +1 -1
- package/zh/apis/app/hooks/index.md +0 -5
- package/zh/apis/app/hooks/shared.md +0 -1
- package/zh/apis/app/hooks/src/app.md +16 -9
- package/zh/apis/app/hooks/src/index_.md +0 -2
- package/zh/apis/app/hooks/src/routes.md +6 -7
- package/zh/apis/app/hooks/src/server.md +6 -4
- package/zh/apis/app/hooks/src/stories.md +1 -1
- package/zh/apis/app/hooks/src/test.md +1 -1
- package/zh/apis/app/runtime/app/define-config.md +1 -2
- package/zh/apis/app/runtime/bff/hook.md +3 -3
- package/zh/apis/app/runtime/core/bootstrap.md +2 -3
- package/zh/apis/app/runtime/core/use-loader.md +2 -2
- package/zh/apis/app/runtime/core/use-module-apps.md +53 -50
- package/zh/apis/app/runtime/core/use-runtime-context.md +3 -4
- package/zh/apis/app/runtime/index.md +0 -5
- package/zh/apis/app/runtime/model/Provider.md +1 -0
- package/zh/apis/app/runtime/model/auto-actions.md +1 -1
- package/zh/apis/app/runtime/model/connect.md +9 -5
- package/zh/apis/app/runtime/model/create-app.md +3 -3
- package/zh/apis/app/runtime/model/create-store.md +2 -4
- package/zh/apis/app/runtime/model/handle-effect.md +3 -4
- package/zh/apis/app/runtime/model/model_.md +0 -3
- package/zh/apis/app/runtime/model/use-local-model.md +0 -1
- package/zh/apis/app/runtime/model/use-store.md +0 -2
- package/zh/apis/app/runtime/router/router.md +23 -53
- package/zh/apis/app/runtime/ssr/no-ssr.md +1 -5
- package/zh/apis/app/runtime/ssr/pre-render.md +10 -6
- package/zh/apis/app/runtime/testing/cleanup.md +2 -2
- package/zh/apis/app/runtime/testing/render.md +0 -2
- package/zh/apis/app/runtime/utility/css-in-js.md +2 -2
- package/zh/apis/app/runtime/utility/head.md +3 -5
- package/zh/apis/app/runtime/utility/loadable.md +14 -15
- package/zh/apis/app/runtime/web-server/hook.md +5 -4
- package/zh/apis/app/runtime/web-server/middleware.md +8 -6
- package/zh/apis/monorepo/commands/bump.md +1 -1
- package/zh/apis/monorepo/commands/change.md +3 -2
- package/zh/apis/monorepo/commands/gen-release-note.md +1 -2
- package/zh/apis/monorepo/commands/index.md +1 -6
- package/zh/apis/monorepo/commands/lint.md +1 -1
- package/zh/apis/monorepo/commands/release.md +0 -1
- package/zh/apis/monorepo/hooks/index.md +1 -6
- package/zh/components/command-tip.md +3 -2
- package/zh/components/enable-bff.md +12 -16
- package/zh/components/enable-micro-frontend.md +4 -4
- package/zh/components/global-proxy-config.md +6 -9
- package/zh/components/global-proxy.md +0 -1
- package/zh/components/init-app.md +0 -1
- package/zh/components/micro-master-manifest-config.md +2 -2
- package/zh/components/micro-runtime-config.md +1 -1
- package/zh/components/reduck-migration.md +0 -1
- package/zh/components/router-legacy-tip.md +0 -1
- package/zh/configure/app/auto-load-plugin.md +9 -10
- package/zh/configure/app/bff/prefix.md +6 -10
- package/zh/configure/app/bff/proxy.md +9 -8
- package/zh/configure/app/builder-plugins.md +6 -6
- package/zh/configure/app/deploy/microFrontend.md +11 -11
- package/zh/configure/app/dev/asset-prefix.md +2 -2
- package/zh/configure/app/dev/hmr.md +2 -2
- package/zh/configure/app/dev/https.md +2 -2
- package/zh/configure/app/dev/port.md +2 -2
- package/zh/configure/app/dev/progress-bar.md +2 -2
- package/zh/configure/app/dev/proxy.md +0 -1
- package/zh/configure/app/dev/start-url.md +2 -2
- package/zh/configure/app/experiments/lazy-compilation.md +2 -2
- package/zh/configure/app/html/app-icon.md +2 -2
- package/zh/configure/app/html/crossorigin.md +2 -2
- package/zh/configure/app/html/disable-html-folder.md +2 -2
- package/zh/configure/app/html/favicon-by-entries.md +2 -2
- package/zh/configure/app/html/favicon.md +2 -2
- package/zh/configure/app/html/inject-by-entries.md +2 -2
- package/zh/configure/app/html/inject.md +2 -2
- package/zh/configure/app/html/meta-by-entries.md +2 -2
- package/zh/configure/app/html/meta.md +2 -2
- package/zh/configure/app/html/mount-id.md +2 -2
- package/zh/configure/app/html/tags-by-entries.md +12 -0
- package/zh/configure/app/html/tags.md +12 -0
- package/zh/configure/app/html/template-by-entries.md +2 -2
- package/zh/configure/app/html/template-parameters-by-entries.md +2 -2
- package/zh/configure/app/html/template-parameters.md +2 -2
- package/zh/configure/app/html/template.md +2 -2
- package/zh/configure/app/html/title-by-entries.md +2 -2
- package/zh/configure/app/html/title.md +2 -2
- package/zh/configure/app/output/asset-prefix.md +2 -2
- package/zh/configure/app/output/assets-retry.md +2 -2
- package/zh/configure/app/output/charset.md +2 -2
- package/zh/configure/app/output/clean-dist-path.md +2 -2
- package/zh/configure/app/output/convert-to-rem.md +2 -2
- package/zh/configure/app/output/copy.md +2 -2
- package/zh/configure/app/output/css-module-local-ident-name.md +2 -2
- package/zh/configure/app/output/data-uri-limit.md +2 -2
- package/zh/configure/app/output/disable-css-extract.md +2 -2
- package/zh/configure/app/output/disable-css-module-extension.md +2 -2
- package/zh/configure/app/output/disable-filename-hash.md +2 -2
- package/zh/configure/app/output/disable-inline-runtime-chunk.md +2 -2
- package/zh/configure/app/output/disable-minimize.md +2 -2
- package/zh/configure/app/output/disable-node-polyfill.md +8 -8
- package/zh/configure/app/output/disable-source-map.md +2 -2
- package/zh/configure/app/output/disable-ts-checker.md +2 -2
- package/zh/configure/app/output/dist-path.md +2 -2
- package/zh/configure/app/output/enable-asset-fallback.md +2 -2
- package/zh/configure/app/output/enable-asset-manifest.md +2 -2
- package/zh/configure/app/output/enable-css-module-tsdeclaration.md +2 -2
- package/zh/configure/app/output/enable-inline-scripts.md +2 -2
- package/zh/configure/app/output/enable-inline-styles.md +2 -2
- package/zh/configure/app/output/enable-latest-decorators.md +2 -2
- package/zh/configure/app/output/externals.md +2 -2
- package/zh/configure/app/output/filename.md +2 -2
- package/zh/configure/app/output/legal-comments.md +2 -2
- package/zh/configure/app/output/override-browserslist.md +2 -2
- package/zh/configure/app/output/polyfill.md +2 -2
- package/zh/configure/app/output/ssg.md +3 -2
- package/zh/configure/app/output/svg-default-export.md +2 -2
- package/zh/configure/app/performance/build-cache.md +2 -2
- package/zh/configure/app/performance/bundle-analyze.md +2 -2
- package/zh/configure/app/performance/chunk-split.md +2 -2
- package/zh/configure/app/performance/print-file-size.md +2 -2
- package/zh/configure/app/performance/profile.md +2 -2
- package/zh/configure/app/performance/remove-console.md +2 -2
- package/zh/configure/app/performance/remove-moment-locale.md +2 -2
- package/zh/configure/app/plugins.md +6 -6
- package/zh/configure/app/runtime/intro.md +12 -11
- package/zh/configure/app/runtime/master-app.md +1 -2
- package/zh/configure/app/runtime/router.md +6 -7
- package/zh/configure/app/runtime/state.md +15 -16
- package/zh/configure/app/security/sri.md +2 -2
- package/zh/configure/app/server/base-url.md +3 -6
- package/zh/configure/app/server/enable-framework-ext.md +5 -4
- package/zh/configure/app/server/port.md +24 -6
- package/zh/configure/app/server/public-routes.md +6 -8
- package/zh/configure/app/server/routes.md +6 -6
- package/zh/configure/app/server/ssr-by-entries.md +5 -8
- package/zh/configure/app/server/ssr.md +4 -5
- package/zh/configure/app/source/alias.md +2 -2
- package/zh/configure/app/source/compile-js-data-uri.md +2 -2
- package/zh/configure/app/source/config-dir.md +2 -2
- package/zh/configure/app/source/define.md +2 -2
- package/zh/configure/app/source/design-system.md +656 -630
- package/zh/configure/app/source/disable-default-entries.md +3 -3
- package/zh/configure/app/source/disable-entry-dirs.md +8 -7
- package/zh/configure/app/source/enable-async-entry.md +3 -3
- package/zh/configure/app/source/entries-dir.md +7 -7
- package/zh/configure/app/source/entries.md +5 -6
- package/zh/configure/app/source/exclude.md +2 -2
- package/zh/configure/app/source/global-vars.md +2 -2
- package/zh/configure/app/source/include.md +2 -2
- package/zh/configure/app/source/module-scopes.md +2 -2
- package/zh/configure/app/source/pre-entry.md +2 -2
- package/zh/configure/app/source/resolve-extension-prefix.md +2 -2
- package/zh/configure/app/source/resolve-main-fields.md +2 -2
- package/zh/configure/app/testing/transformer.md +2 -3
- package/zh/configure/app/tools/autoprefixer.md +2 -2
- package/zh/configure/app/tools/babel.md +2 -2
- package/zh/configure/app/tools/css-extract.md +2 -2
- package/zh/configure/app/tools/css-loader.md +2 -2
- package/zh/configure/app/tools/dev-server.md +2 -2
- package/zh/configure/app/tools/html-plugin.md +2 -2
- package/zh/configure/app/tools/inspector.md +2 -2
- package/zh/configure/app/tools/jest.md +9 -9
- package/zh/configure/app/tools/less.md +2 -2
- package/zh/configure/app/tools/minify-css.md +2 -2
- package/zh/configure/app/tools/postcss.md +2 -2
- package/zh/configure/app/tools/pug.md +2 -2
- package/zh/configure/app/tools/sass.md +2 -2
- package/zh/configure/app/tools/style-loader.md +2 -2
- package/zh/configure/app/tools/styled-components.md +2 -2
- package/zh/configure/app/tools/swc.md +12 -1
- package/zh/configure/app/tools/terser.md +2 -2
- package/zh/configure/app/tools/ts-checker.md +2 -2
- package/zh/configure/app/tools/ts-loader.md +2 -2
- package/zh/configure/app/tools/webpack-chain.md +2 -2
- package/zh/configure/app/tools/webpack.md +2 -2
- package/zh/guides/advanced-features/bff/frameworks.md +6 -6
- package/zh/guides/advanced-features/bff/function.md +49 -44
- package/zh/guides/advanced-features/bff/index.md +9 -9
- package/zh/guides/advanced-features/bff/type.md +0 -1
- package/zh/guides/advanced-features/code-split.md +3 -3
- package/zh/guides/advanced-features/compatibility.md +6 -7
- package/zh/guides/advanced-features/eslint.md +0 -1
- package/zh/guides/advanced-features/index.md +0 -5
- package/zh/guides/advanced-features/low-level.md +17 -19
- package/zh/guides/advanced-features/ssg.md +8 -9
- package/zh/guides/advanced-features/ssr.md +5 -11
- package/zh/guides/advanced-features/testing.md +3 -2
- package/zh/guides/advanced-features/web-server.md +3 -4
- package/zh/guides/basic-features/alias.md +7 -11
- package/zh/guides/basic-features/css/css-in-js.md +5 -5
- package/zh/guides/basic-features/css/css-modules.md +2 -2
- package/zh/guides/basic-features/css/postcss.md +42 -46
- package/zh/guides/basic-features/css/tailwindcss.md +5 -5
- package/zh/guides/basic-features/data-fetch.md +109 -192
- package/zh/guides/basic-features/env-vars.md +7 -6
- package/zh/guides/basic-features/html.md +54 -46
- package/zh/guides/basic-features/index.md +0 -5
- package/zh/guides/basic-features/mock.md +4 -4
- package/zh/guides/basic-features/proxy.md +4 -5
- package/zh/guides/basic-features/routes.md +23 -20
- package/zh/guides/concept/entries.md +5 -7
- package/zh/guides/get-started/quick-start.md +3 -4
- package/zh/guides/topic-detail/changesets/add.md +1 -3
- package/zh/guides/topic-detail/changesets/changelog.md +30 -31
- package/zh/guides/topic-detail/changesets/commit.md +44 -45
- package/zh/guides/topic-detail/changesets/config.md +2 -1
- package/zh/guides/topic-detail/changesets/github.md +6 -10
- package/zh/guides/topic-detail/changesets/introduce.md +0 -1
- package/zh/guides/topic-detail/changesets/release-note.md +9 -12
- package/zh/guides/topic-detail/changesets/release-pre.md +1 -1
- package/zh/guides/topic-detail/framework-plugin/extend.md +13 -13
- package/zh/guides/topic-detail/framework-plugin/hook-list.md +2 -2
- package/zh/guides/topic-detail/framework-plugin/hook.md +57 -54
- package/zh/guides/topic-detail/framework-plugin/implement.md +11 -11
- package/zh/guides/topic-detail/framework-plugin/plugin-api.md +4 -4
- package/zh/guides/topic-detail/generator/codesmith/api/app.md +36 -36
- package/zh/guides/topic-detail/generator/codesmith/api/ejs.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/fs.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/git.md +3 -2
- package/zh/guides/topic-detail/generator/codesmith/api/handlebars.md +2 -2
- package/zh/guides/topic-detail/generator/codesmith/api/json.md +9 -11
- package/zh/guides/topic-detail/generator/codesmith/api/npm.md +4 -2
- package/zh/guides/topic-detail/generator/codesmith/introduce.md +20 -7
- package/zh/guides/topic-detail/generator/codesmith/run-in-js.md +4 -5
- package/zh/guides/topic-detail/generator/codesmith/structure.md +13 -10
- package/zh/guides/topic-detail/generator/config/common.md +18 -27
- package/zh/guides/topic-detail/generator/plugin/abstract.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/file/introduce.md +1 -0
- package/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.md +4 -4
- package/zh/guides/topic-detail/generator/plugin/api/info/locale.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.md +2 -2
- package/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.md +3 -4
- package/zh/guides/topic-detail/generator/plugin/api/input/setInput.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/input/type.md +1 -1
- package/zh/guides/topic-detail/generator/plugin/api/introduce.md +8 -9
- package/zh/guides/topic-detail/generator/plugin/develop.md +13 -13
- package/zh/guides/topic-detail/generator/plugin/use.md +8 -8
- package/zh/guides/topic-detail/generator/project.md +1 -1
- package/zh/guides/topic-detail/micro-frontend/c01-introduction.md +7 -8
- package/zh/guides/topic-detail/micro-frontend/c02-development.md +20 -23
- package/zh/guides/topic-detail/micro-frontend/c03-main-app.md +41 -44
- package/zh/guides/topic-detail/micro-frontend/c04-communicate.md +7 -5
- package/zh/guides/topic-detail/micro-frontend/c05-mixed-stack.md +1 -1
- package/zh/guides/topic-detail/model/auto-actions.md +0 -1
- package/zh/guides/topic-detail/model/computed-state.md +0 -2
- package/zh/guides/topic-detail/model/define-model.md +3 -6
- package/zh/guides/topic-detail/model/faq.md +2 -5
- package/zh/guides/topic-detail/model/manage-effects.md +2 -5
- package/zh/guides/topic-detail/model/model-communicate.md +1 -4
- package/zh/guides/topic-detail/model/performance.md +1 -5
- package/zh/guides/topic-detail/model/quick-start.md +0 -6
- package/zh/guides/topic-detail/model/redux-integration.md +3 -2
- package/zh/guides/topic-detail/model/test-model.md +1 -1
- package/zh/guides/topic-detail/model/typescript-best-practice.md +13 -14
- package/zh/guides/topic-detail/model/use-model.md +14 -12
- package/zh/guides/topic-detail/model/use-out-of-modernjs.md +4 -6
- package/zh/guides/topic-detail/monorepo/intro.md +0 -1
- package/zh/guides/topic-detail/monorepo/sub-project-interface.md +14 -7
- package/zh/tutorials/first-app/c01-start.md +2 -2
- package/zh/tutorials/first-app/c03-css.md +6 -9
- package/zh/tutorials/first-app/c04-routes.md +1 -1
- package/zh/tutorials/first-app/c05-loader.md +2 -1
- package/zh/tutorials/first-app/c07-container.md +6 -7
- package/zh/tutorials/first-app/c08-entries.md +5 -7
@@ -10,67 +10,63 @@ By default, Modern.js compile and transform CSS as follows:
|
|
10
10
|
|
11
11
|
1. [Autoprefixer](https://github.com/postcss/autoprefixer) Automatically add the required browser vendor prefix to CSS rules according to the required browser range. Modern.js default supported browser ranges are: `['> 0.01%', 'not dead', 'not op_mini all']`.
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
{
|
24
|
-
"Browserslist": [
|
25
|
-
"The last 1 versions",
|
26
|
-
"> 1%",
|
27
|
-
"IE 10"
|
28
|
-
]
|
29
|
-
}
|
30
|
-
```
|
31
|
-
:::
|
13
|
+
:::info Note
|
14
|
+
- [Supported browser range: `> 0.01%`] means that the browser market share is greater than 0.01%.
|
15
|
+
- `Not dead` means excluding browsers that are no longer officially supported and browsers that have not been updated in the past 24 months.
|
16
|
+
- `not op_mini all` means exclude Opera Mini.
|
17
|
+
:::
|
18
|
+
|
19
|
+
:::info Additional
|
20
|
+
If you need to modify the default browser support range, you can configure `browserslist` in the project's `package.json` file, and set the rule to refer to the use of [Browserslist](https://github.com/browserslist/browserslist). The following is an example:
|
21
|
+
`json title ="package.json" { "Browserslist": [ "The last 1 versions", "> 1%", "IE 10" ] } `
|
22
|
+
:::
|
32
23
|
|
33
24
|
2. Provide [CSS custom properties](https://www.w3.org/TR/css-variables-1/) support, you can define and use custom variables in CSS, such as:
|
34
25
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
26
|
+
```css
|
27
|
+
:root {
|
28
|
+
--main-bg-color: pink;
|
29
|
+
}
|
30
|
+
|
31
|
+
body {
|
32
|
+
background-color: var(--main-bg-color);
|
33
|
+
}
|
34
|
+
```
|
39
35
|
|
40
|
-
body {
|
41
|
-
background-color: var(--main-bg-color);
|
42
|
-
}
|
43
|
-
```
|
44
36
|
3. Provide [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) support, you can use nested writing in CSS, such as:
|
45
37
|
|
46
|
-
|
47
|
-
|
38
|
+
```css
|
39
|
+
table.colortable td {
|
40
|
+
text-align: center;
|
41
|
+
}
|
42
|
+
table.colortable td.c {
|
43
|
+
text-transform: uppercase;
|
44
|
+
}
|
45
|
+
```
|
46
|
+
|
47
|
+
It can also be rewritten as CSS nested:
|
48
|
+
|
49
|
+
```css
|
50
|
+
table.colortable {
|
51
|
+
& td {
|
48
52
|
text-align: center;
|
49
|
-
|
50
|
-
|
51
|
-
text-transform: uppercase;
|
52
|
-
}
|
53
|
-
```
|
54
|
-
It can also be rewritten as CSS nested:
|
55
|
-
```css
|
56
|
-
table.colortable {
|
57
|
-
& td {
|
58
|
-
text-align: center;
|
59
|
-
&.c { text-transform: uppercase }
|
53
|
+
&.c {
|
54
|
+
text-transform: uppercase;
|
60
55
|
}
|
61
56
|
}
|
62
|
-
|
57
|
+
}
|
58
|
+
```
|
63
59
|
|
64
60
|
4. Fix known [Flexbugs](https://github.com/philipwalton/flexbugs).
|
65
61
|
5. Provide compatibility with the following CSS features:
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
62
|
+
- [`initial` attribute value](https://developer.mozilla.org/en-US/docs/Web/CSS/initial_value)
|
63
|
+
- [`break-` attribute](https://developer.mozilla.org/en-US/docs/Web/CSS/break-after)
|
64
|
+
- [`font-variant`](https://developer.mozilla.org/en-US/docs/Web/CSS/font-variant)
|
65
|
+
- [Media Query Ranges](https://developer.mozilla.org/en-US/docs/Web/CSS/Media_Queries/Using_media_queries#syntax_improvements_in_level_4)
|
70
66
|
|
71
|
-
|
67
|
+
When you need to modify the PostCSS configuration, you can implement it through the underlying configuration [`tools.postcss`](/docs/configure/app/tools/postcss), here is an example:
|
72
68
|
|
73
|
-
```
|
69
|
+
```ts title="modern.config.ts"
|
74
70
|
export default defineConfig({
|
75
71
|
tools: {
|
76
72
|
postcss: {
|
@@ -57,7 +57,7 @@ If you use Tailwind CSS on IE 11 browser, some styles may not be available, plea
|
|
57
57
|
|
58
58
|
When you need to customize the [theme](https://tailwindcss.com/docs/theme) configuration of Tailwind CSS, you can modify it in the configuration [`source.designSystem`](/docs/configure/app/source/design-system), for example, add a color theme `primary`:
|
59
59
|
|
60
|
-
```
|
60
|
+
```ts title="modern.config.ts"
|
61
61
|
export default defineConfig({
|
62
62
|
source: {
|
63
63
|
designSystem: {
|
@@ -73,7 +73,7 @@ export default defineConfig({
|
|
73
73
|
|
74
74
|
When you need special configuration for Tailwind CSS other than [theme](https://tailwindcss.com/docs/theme), you can configure it in [`tools.tailwindcss`](/docs/configure/app/tools/tailwindcss), for example setting `variants`:
|
75
75
|
|
76
|
-
```
|
76
|
+
```ts title="modern.config.ts"
|
77
77
|
export default defineConfig({
|
78
78
|
tools: {
|
79
79
|
tailwindcss: {
|
@@ -9,7 +9,7 @@ It should be noted that these APIs do not help applications to initiate requests
|
|
9
9
|
|
10
10
|
## Data loader(recommend)
|
11
11
|
|
12
|
-
Modern.js recommends the use of conventional routing for route management. With Modern.js' [conventional (nested) routing](/docs/guides/basic-features/routes#conventional-routing), each routing component (`layout.ts` or `page.ts`) can
|
12
|
+
Modern.js recommends the use of conventional routing for route management. With Modern.js' [conventional (nested) routing](/docs/guides/basic-features/routes#conventional-routing), each routing component (`layout.ts` or `page.ts`) can have a `loader` file with the same name that can be executed before the component renders, providing data to the routing component.
|
13
13
|
|
14
14
|
:::info
|
15
15
|
Modern.js v1 supports getting data by [useLoader](#useloaderold), which is no longer the recommended usage and it is not recommended to mix both except for migration process.
|
@@ -17,36 +17,7 @@ Modern.js v1 supports getting data by [useLoader](#useloaderold), which is no lo
|
|
17
17
|
|
18
18
|
### Basic example
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
```ts
|
23
|
-
// routes/user/page.tsx
|
24
|
-
import { useLoaderData } from '@modern-js/runtime/router';
|
25
|
-
|
26
|
-
export const loader = async(): ProfileData => {
|
27
|
-
const res = await fetch('https://api/user/profile');
|
28
|
-
return await res.json();
|
29
|
-
}
|
30
|
-
|
31
|
-
export default function UserPage() {
|
32
|
-
const profileData = useLoaderData() as ProfileData;
|
33
|
-
return <div>{profileData}</div>;
|
34
|
-
}
|
35
|
-
```
|
36
|
-
|
37
|
-
In a CSR environment, the `loader` function is executed on the client side, and the browser API can be used within the `loader` function (but it is usually not needed and not recommended).
|
38
|
-
|
39
|
-
In an SSR environment, the `loader` function will only be executed on the server side, regardless of the first screen or the navigation on the client side, where any Node.js API can be called, and any dependencies and code used here will not be included in the client bundle.
|
40
|
-
|
41
|
-
:::info
|
42
|
-
In later versions, Modern.js may support `loader` functions running on the server side as well in CSR environments to improve performance and security, so here it is recommended to keep the loader as pure as possible and only do data fetching scenarios.
|
43
|
-
:::
|
44
|
-
|
45
|
-
When navigating on the client side, all loader functions under `/user` and `/user/profile` are executed (requested) in parallel based on Modern.js's [conventional routing](/docs/guides/basic-features/routes), i.e. when accessing `/user/profile`, the loader functions under `/user` and `/user/profile` are executed (requested) in parallel to improve client-side performance.
|
46
|
-
|
47
|
-
### Loader is defined in a separate file
|
48
|
-
|
49
|
-
In addition to supporting the export of `loader` functions from front-end components, Modern.js also supports placing `loader` functions in a separate file, by defining the `loader` function in a separate file, there is no need to pay attention to [side effect](#side-effects) related considerations, but it is important to note that routing components such as `layout.ts` and the loader file `layout.loader.ts` cannot introduce each other's code, if you need the related types you can use `import type`, you can see the following example:
|
20
|
+
A routing component such as `layout.ts` or `page.ts` can define a `loader` file with the same name. The `loader` file exports a function that provides the data required by the component, which is then get data by the `useLoaderData` function in the routing component, as in the following example:
|
50
21
|
|
51
22
|
```
|
52
23
|
.
|
@@ -59,21 +30,11 @@ In addition to supporting the export of `loader` functions from front-end compon
|
|
59
30
|
└── page.loader.ts
|
60
31
|
```
|
61
32
|
|
62
|
-
|
33
|
+
Define the following code in the file:
|
63
34
|
|
64
|
-
```tsx
|
65
|
-
// routes/user/page.loader.tsx
|
66
|
-
type ProfileData = { /* some type declarations */ }
|
67
|
-
|
68
|
-
export const loader = async(): ProfileData => {
|
69
|
-
const res = await fetch('https://api/user/profile');
|
70
|
-
return await res.json();
|
71
|
-
}
|
72
|
-
|
73
|
-
// routes/user/page.tsx
|
35
|
+
```ts title="routes/user/page.tsx"
|
74
36
|
import { useLoaderData } from '@modern-js/runtime/router';
|
75
|
-
|
76
|
-
import type { ProfileData } from './page.loader';
|
37
|
+
import type { ProfileData } from './page.loader.ts';
|
77
38
|
|
78
39
|
export default function UserPage() {
|
79
40
|
const profileData = useLoaderData() as ProfileData;
|
@@ -81,6 +42,31 @@ export default function UserPage() {
|
|
81
42
|
}
|
82
43
|
```
|
83
44
|
|
45
|
+
```ts title="routes/user/page.loader.ts"
|
46
|
+
export type ProfileData = {
|
47
|
+
/* some types */
|
48
|
+
};
|
49
|
+
|
50
|
+
export default async (): Promise<ProfileData> => {
|
51
|
+
const res = await fetch('https://api/user/profile');
|
52
|
+
return await res.json();
|
53
|
+
};
|
54
|
+
```
|
55
|
+
|
56
|
+
:::caution
|
57
|
+
Here the routing component and the `loader` file share a type, should use the `import type` syntax.
|
58
|
+
:::
|
59
|
+
|
60
|
+
In a CSR environment, the `loader` function is executed on the client side, and the browser API can be used within the `loader` function (but it is usually not needed and not recommended).
|
61
|
+
|
62
|
+
In an SSR environment, the `loader` function will only be executed on the server side, regardless of the first screen or the navigation on the client side, where any Node.js API can be called, and any dependencies and code used here will not be included in the client bundle.
|
63
|
+
|
64
|
+
:::info
|
65
|
+
In later versions, Modern.js may support `loader` functions running on the server side as well in CSR environments to improve performance and security, so here it is recommended to keep the loader as pure as possible and only do data fetching scenarios.
|
66
|
+
:::
|
67
|
+
|
68
|
+
When navigating on the client side, all loader functions under `/user` and `/user/profile` are executed (requested) in parallel based on Modern.js's [conventional routing](/docs/guides/basic-features/routes), i.e. when accessing `/user/profile`, the loader functions under `/user` and `/user/profile` are executed (requested) in parallel to improve client-side performance.
|
69
|
+
|
84
70
|
### `loader` function
|
85
71
|
|
86
72
|
The `loader` function has two input parameters:
|
@@ -90,14 +76,14 @@ The `loader` function has two input parameters:
|
|
90
76
|
When a routing file is passed through `[]`, it is passed as a [dynamic route](/docs/guides/basic-features/routes#dynamic-route) and the dynamic route fragment is passed as an argument to the loader function:
|
91
77
|
|
92
78
|
```tsx
|
93
|
-
// routes/user/[id]/page.tsx
|
79
|
+
// routes/user/[id]/page.loader.tsx
|
94
80
|
import { LoaderArgs } from '@modern-js/runtime/router';
|
95
81
|
|
96
|
-
export
|
82
|
+
export default async ({ params }: LoaderArgs) => {
|
97
83
|
const { id } = params;
|
98
84
|
const res = await fetch(`https://api/user/${id}`);
|
99
85
|
return res.json();
|
100
|
-
}
|
86
|
+
};
|
101
87
|
```
|
102
88
|
|
103
89
|
当访问 `/user/123` 时,`loader` 函数的参数为 `{ params: { id: '123' } }`。
|
@@ -107,41 +93,43 @@ export const loader = async({ params }: LoaderArgs) => {
|
|
107
93
|
`request` is a [Fetch Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) instance.
|
108
94
|
|
109
95
|
A common usage scenario is to obtain query parameters via `request`:
|
96
|
+
|
110
97
|
```tsx
|
111
|
-
// routes/user/[id]/page.
|
98
|
+
// routes/user/[id]/page.loader.ts
|
112
99
|
import { LoaderArgs } from '@modern-js/runtime/router';
|
113
100
|
|
114
|
-
export
|
101
|
+
export default async ({ request }: LoaderArgs) => {
|
115
102
|
const url = new URL(request.url);
|
116
|
-
const userId = url.searchParams.get(
|
103
|
+
const userId = url.searchParams.get('id');
|
117
104
|
return queryUser(userId);
|
118
|
-
}
|
105
|
+
};
|
119
106
|
```
|
120
107
|
|
121
108
|
#### Return value
|
122
109
|
|
123
|
-
`loader`
|
110
|
+
The return value of the `loader` function can be anything serializable, or it can be a [Fetch Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) instance:
|
124
111
|
|
125
112
|
```tsx
|
126
|
-
|
113
|
+
const loader = async (): Promise<ProfileData> => {
|
127
114
|
return {
|
128
115
|
message: 'hello world',
|
129
|
-
}
|
130
|
-
}
|
116
|
+
};
|
117
|
+
};
|
118
|
+
export default loader;
|
131
119
|
```
|
132
120
|
|
133
121
|
By default, the response `Content-type` returned by `loader` is `application/json` and `status` is 200, which you can set by customizing `Response`:
|
134
122
|
|
135
123
|
```tsx
|
136
|
-
|
137
|
-
const data = {message: 'hello world'};
|
124
|
+
const loader = async (): Promise<ProfileData> => {
|
125
|
+
const data = { message: 'hello world' };
|
138
126
|
return new Response(JSON.stringify(data), {
|
139
127
|
status: 200,
|
140
128
|
headers: {
|
141
|
-
|
129
|
+
'Content-Type': 'application/json; utf-8',
|
142
130
|
},
|
143
131
|
});
|
144
|
-
}
|
132
|
+
};
|
145
133
|
```
|
146
134
|
|
147
135
|
### Request API
|
@@ -149,7 +137,7 @@ export const loader = async(): ProfileData => {
|
|
149
137
|
Modern.js does a polyfill of the `fetch` API to initiate requests, which is consistent with the browser's `fetch` API, but can also be used on the server side to initiate requests, meaning that both CSRs and SSRs can use the unified `fetch` API for data fetching:
|
150
138
|
|
151
139
|
```tsx
|
152
|
-
|
140
|
+
function loader() {
|
153
141
|
const res = await fetch('https://api/user/profile');
|
154
142
|
}
|
155
143
|
```
|
@@ -159,10 +147,10 @@ export async function loader(){
|
|
159
147
|
In the `loader` function, errors can be handled by `throw error` or `throw response`. When an error is thrown in the `loader` function, Modern.js will stop executing the code in the current loader and switch the front-end UI to the defined [`ErrorBoundary`](/docs/guides/basic-features/routes#errorboundary) component.
|
160
148
|
|
161
149
|
```tsx
|
162
|
-
// routes/user/profile/page.tsx
|
163
|
-
export async function loader(){
|
150
|
+
// routes/user/profile/page.loader.tsx
|
151
|
+
export default async function loader() {
|
164
152
|
const res = await fetch('https://api/user/profile');
|
165
|
-
if(!res.ok){
|
153
|
+
if (!res.ok) {
|
166
154
|
throw res;
|
167
155
|
}
|
168
156
|
return res.json();
|
@@ -192,7 +180,7 @@ In many cases, the child component needs to access the data in the ancestor's lo
|
|
192
180
|
import { useRouteLoaderData } from '@modern-js/runtime/router';
|
193
181
|
|
194
182
|
export default function UserLayout() {
|
195
|
-
// Get the data returned by the loader in routes/user/layout.
|
183
|
+
// Get the data returned by the loader in routes/user/layout.loader.ts
|
196
184
|
const data = useRouteLoaderData('user/layout');
|
197
185
|
return (
|
198
186
|
<div>
|
@@ -203,19 +191,22 @@ export default function UserLayout() {
|
|
203
191
|
}
|
204
192
|
```
|
205
193
|
|
206
|
-
`userRouteLoaderData` takes one parameter `routeId`,When using conventional routing, Modern.js will automatically generate `routeId` for you. The value of `routeId` is the path of the corresponding component relative to `src/routes`, as in the example above, the child component wants to get the data returned by the loader in `routes/user/layout.tsx`, the value of `routeId` is
|
194
|
+
`userRouteLoaderData` takes one parameter `routeId`,When using conventional routing, Modern.js will automatically generate `routeId` for you. The value of `routeId` is the path of the corresponding component relative to `src/routes`, as in the example above, the child component wants to get the data returned by the loader in `routes/user/layout.tsx`, the value of `routeId` is `user/layout`.
|
207
195
|
|
208
196
|
In a multi-entry (MPA) scenario, the value of `routeId` needs to be added to the name of the corresponding entry, and the entry name is usually the entry directory name if not specified, such as the following directory structure:
|
197
|
+
|
209
198
|
```bash
|
210
199
|
.
|
211
200
|
└── src
|
212
201
|
├── entry1
|
213
|
-
│
|
202
|
+
│ └── routes
|
203
|
+
│ └── layout.tsx
|
214
204
|
└── entry2
|
215
|
-
|
205
|
+
└── routes
|
206
|
+
└── layout.tsx
|
216
207
|
```
|
217
208
|
|
218
|
-
If you want to get the data returned by the loader in `entry1/layout.tsx`, the value of `routeId` is `entry1_layout`.
|
209
|
+
If you want to get the data returned by the loader in `entry1/routes/layout.tsx`, the value of `routeId` is `entry1_layout`.
|
219
210
|
|
220
211
|
### (WIP)Loading UI
|
221
212
|
|
@@ -224,35 +215,7 @@ This feature is currently experimental and the API may be adjusted in the future
|
|
224
215
|
Currently, only CSR is supported, so stay tuned for Streaming SSR.
|
225
216
|
:::
|
226
217
|
|
227
|
-
|
228
|
-
|
229
|
-
```bash
|
230
|
-
.
|
231
|
-
└── routes
|
232
|
-
├── layout.tsx
|
233
|
-
└── user
|
234
|
-
├── layout.tsx
|
235
|
-
└── page.ts
|
236
|
-
```
|
237
|
-
|
238
|
-
We get the user's detailed data in `user/layout.tsx` and want to show a loading UI before getting the data.
|
239
|
-
|
240
|
-
First, add a `loading.tsx` component to the `routes` directory in your project, which will take effect for all routes in the subdirectory (e.g. user):
|
241
|
-
```bash
|
242
|
-
.
|
243
|
-
└── routes
|
244
|
-
├── layout.tsx
|
245
|
-
├── loading.tsx
|
246
|
-
└── user
|
247
|
-
├── layout.tsx
|
248
|
-
└── page.ts
|
249
|
-
```
|
250
|
-
|
251
|
-
:::info
|
252
|
-
For specific usage of the loading component, see [loading](/docs/guides/basic-features/routes#loading)
|
253
|
-
:::
|
254
|
-
|
255
|
-
Then, add the following code to `user/layout.tsx`:
|
218
|
+
Add the following code to `user/layout.tsx`:
|
256
219
|
|
257
220
|
```tsx title="routes/user/layout.tsx"
|
258
221
|
import {
|
@@ -273,14 +236,18 @@ export default function UserLayout() {
|
|
273
236
|
const { userInfo } = useLoaderData() as {userInfo: Promise<UserInfo>};
|
274
237
|
return (
|
275
238
|
<div>
|
276
|
-
<
|
277
|
-
<
|
278
|
-
|
279
|
-
|
280
|
-
<
|
281
|
-
|
282
|
-
|
283
|
-
|
239
|
+
<React.Suspense
|
240
|
+
fallback={<p>Loading...</p>}
|
241
|
+
>
|
242
|
+
<Await resolve={userInfo} children={userInfo => (
|
243
|
+
<div>
|
244
|
+
<span>{userInfo.name}</span>
|
245
|
+
<span>{userInfo.age}</span>
|
246
|
+
<Outlet>
|
247
|
+
</div>
|
248
|
+
)}>
|
249
|
+
</Await>
|
250
|
+
</React.Suspense>
|
284
251
|
</div>
|
285
252
|
);
|
286
253
|
}
|
@@ -292,84 +259,6 @@ For specific usage of the Await component, see [Await](/docs/guides/basic-featur
|
|
292
259
|
For specific usage of the defer function, see[defer](https://reactrouter.com/en/main/guides/deferred)
|
293
260
|
:::
|
294
261
|
|
295
|
-
### Side Effects
|
296
|
-
|
297
|
-
As mentioned above, Modern.js removes the server-side code `loader` from the client bundle, there are some things you need to be aware of, if you don't want to suffer from side effects, you can define `loader` in a [separate file](#loader-is-defined-in-a-separate-file).
|
298
|
-
|
299
|
-
:::info
|
300
|
-
In CSR scenarios, the side effects usually have less impact on the project, but you are still expected to follow the following conventions.
|
301
|
-
:::
|
302
|
-
|
303
|
-
Side effects of a module can be thought of as code that is executed when the module is loaded, such as:
|
304
|
-
|
305
|
-
```tsx
|
306
|
-
// routes/user/page.tsx
|
307
|
-
import { useLoaderData } from '@modern-js/runtime/router';
|
308
|
-
// highlight-next-line
|
309
|
-
import { transformProfile } from "./utils";
|
310
|
-
// highlight-next-line
|
311
|
-
console.log(transformProfile);
|
312
|
-
|
313
|
-
export const loader = async(): ProfileData => {
|
314
|
-
const res = await fetch('https://api/user/profile');
|
315
|
-
const data = await res.json();
|
316
|
-
return transformProfile(data);
|
317
|
-
}
|
318
|
-
|
319
|
-
export default function UserPage() {
|
320
|
-
const profileData = useLoaderData() as ProfileData;
|
321
|
-
return <div>{profileData}</div>;
|
322
|
-
}
|
323
|
-
```
|
324
|
-
|
325
|
-
Since `console.log` is executed when `routes/user/page.tsx` is loaded, the compiler does not remove it and `transformProfile` is bundled into the client bundle.
|
326
|
-
|
327
|
-
So we do not recommend having any code executed when the module is loaded, including project code and third-party modules used, and the following are some of the ways we do not recommend writing.
|
328
|
-
|
329
|
-
```tsx
|
330
|
-
// routes/user/page.tsx
|
331
|
-
export default function UserPage() {
|
332
|
-
return <div>profile</div>;
|
333
|
-
}
|
334
|
-
|
335
|
-
UserPage.config = {}
|
336
|
-
```
|
337
|
-
|
338
|
-
```tsx
|
339
|
-
// routes/init.ts
|
340
|
-
document.title = 'Modern.js';
|
341
|
-
|
342
|
-
// routes/layout.tsx
|
343
|
-
import "./init.ts";
|
344
|
-
|
345
|
-
export default function Layout() {
|
346
|
-
return <></>
|
347
|
-
}
|
348
|
-
```
|
349
|
-
|
350
|
-
In SSR scenarios, you usually need to use Server Side packages in the `loader` function, and for non-Node.js core packages, you need to do a re-export using a specially agreed file, such as using `fs-extra`:
|
351
|
-
|
352
|
-
```tsx
|
353
|
-
// routes/user/avatar.tsx
|
354
|
-
import { useLoaderData } from '@modern-js/runtime/router';
|
355
|
-
import { readFile } from './utils.server';
|
356
|
-
|
357
|
-
type ProfileData = { /* some type declarations */ }
|
358
|
-
|
359
|
-
export const loader = async(): ProfileData => {
|
360
|
-
const profile = await readFile('profile.json');
|
361
|
-
return profile;
|
362
|
-
}
|
363
|
-
|
364
|
-
export default function UserPage() {
|
365
|
-
const profileData = useLoaderData() as ProfileData;
|
366
|
-
return <div>{profileData}</div>;
|
367
|
-
}
|
368
|
-
|
369
|
-
// routes/user/utils.server.ts
|
370
|
-
export * from 'fs-extra';
|
371
|
-
```
|
372
|
-
|
373
262
|
### Wrong usage
|
374
263
|
|
375
264
|
1. Only serializable data can be returned in `loader`. In SSR environments, the return value of the `loader` function is serialized to a JSON string, which is then deserialized to an object on the client side. Therefore, no non-serializable data (such as functions) can be returned in the `loader` function.
|
@@ -380,32 +269,57 @@ This restriction is not currently in place under CSR, but we strongly recommend
|
|
380
269
|
|
381
270
|
```ts
|
382
271
|
// This won't work!
|
383
|
-
export
|
272
|
+
export default () => {
|
384
273
|
return {
|
385
274
|
user: {},
|
386
|
-
method: () => {
|
387
|
-
|
388
|
-
|
389
|
-
}
|
390
|
-
}
|
275
|
+
method: () => {},
|
276
|
+
};
|
277
|
+
};
|
391
278
|
```
|
392
279
|
|
393
280
|
2. Modern.js will call the `loader` function for you, you shouldn't call it yourself in the component.
|
394
281
|
|
395
282
|
```tsx
|
396
283
|
// This won't work!
|
397
|
-
export
|
284
|
+
export default async () => {
|
398
285
|
const res = fetch('https://api/user/profile');
|
399
286
|
return res.json();
|
400
287
|
};
|
401
288
|
|
289
|
+
import loader from './page.loader.ts';
|
402
290
|
export default function RouteComp() {
|
403
291
|
const data = loader();
|
404
292
|
}
|
405
293
|
```
|
406
294
|
|
407
|
-
3.
|
295
|
+
3. You cannot import a `loader` file from a routing component, nor can you import variables in a routing component from a `loader` file:
|
296
|
+
|
297
|
+
```ts
|
298
|
+
// Not allowed
|
299
|
+
// routes/layout.tsx
|
300
|
+
import { useLoaderData } from '@modern-js/runtime/router';
|
301
|
+
import { ProfileData } from './page.loader.ts'; // should use "import type" instead
|
302
|
+
|
303
|
+
export const fetch = wrapFetch(fetch);
|
304
|
+
|
305
|
+
export default function UserPage() {
|
306
|
+
const profileData = useLoaderData() as ProfileData;
|
307
|
+
return <div>{profileData}</div>;
|
308
|
+
}
|
309
|
+
|
310
|
+
// routes/layout.loader.ts
|
311
|
+
import { fetch } from './layout.tsx'; // should not be imported from the routing component
|
312
|
+
export type ProfileData = {
|
313
|
+
/* some types */
|
314
|
+
};
|
315
|
+
|
316
|
+
export default async (): Promise<ProfileData> => {
|
317
|
+
const res = await fetch('https://api/user/profile');
|
318
|
+
return await res.json();
|
319
|
+
};
|
320
|
+
```
|
408
321
|
|
322
|
+
4. When run on the server side, the `loader` functions are packaged into a single bundle, so we do not recommend using `__filename` and `__dirname` for server-side code.
|
409
323
|
|
410
324
|
## useLoader(Old)
|
411
325
|
|
@@ -441,7 +355,7 @@ This is because Modern.js server-side rendering, the data returned by the `useLo
|
|
441
355
|
|
442
356
|
```html
|
443
357
|
<script>
|
444
|
-
window._SSR_DATA = {};
|
358
|
+
window._SSR_DATA = {};
|
445
359
|
</script>
|
446
360
|
```
|
447
361
|
|
@@ -31,15 +31,16 @@ Auto inject when use `@modern-js/runtime`,Used to distinguish between SSR and
|
|
31
31
|
function App() {
|
32
32
|
if (process.env.MODERN_TARGET === 'browser') {
|
33
33
|
console.log(window.innerHeight);
|
34
|
-
}
|
35
|
-
}
|
34
|
+
}
|
35
|
+
}
|
36
36
|
```
|
37
37
|
|
38
38
|
In the development environment, you can see that the SSR and CSR bundles as follows:
|
39
39
|
|
40
40
|
```js title="dist/bundles/main.js"
|
41
41
|
function App() {
|
42
|
-
if (false) {
|
42
|
+
if (false) {
|
43
|
+
}
|
43
44
|
}
|
44
45
|
```
|
45
46
|
|
@@ -80,8 +81,8 @@ BAR=456
|
|
80
81
|
|
81
82
|
The `.env` file follows the following loading rules:
|
82
83
|
|
83
|
-
|
84
|
-
|
84
|
+
- `.env`:default.
|
85
|
+
- `.env.{ MODERN_ENV | NODE_ENV }`:Setting environment variables for a specific environment overrides the same in `.env`.
|
85
86
|
|
86
87
|
When you need to use different config according to the environment, you can define environment variables in the `.env` file corresponding to the environment name, and manually set the execution environment when starting the project.
|
87
88
|
|
@@ -116,14 +117,14 @@ if (true) {
|
|
116
117
|
In custom HTML templates, you can also use such environment variables directly. For example, in `config/html/head.html`:
|
117
118
|
|
118
119
|
```html
|
119
|
-
<meta name="test" content="<process.env.NODE_ENV>"
|
120
|
+
<meta name="test" content="<process.env.NODE_ENV>" />
|
120
121
|
```
|
121
122
|
|
122
123
|
### Any Other Names
|
123
124
|
|
124
125
|
If you need to use environment variables with any other names in your code,you can config [`source.globalVars`](/docs/configure/app/source/global-vars), for example:
|
125
126
|
|
126
|
-
```
|
127
|
+
```ts title="modern.config.ts"
|
127
128
|
export default defineConfig({
|
128
129
|
source: {
|
129
130
|
globalVars: {
|
@@ -143,7 +144,6 @@ At this point, the `process.env.VERSION` in the code will be replaced with the v
|
|
143
144
|
|
144
145
|
In addition to environment variables, Modern.js also supports replacing variables in code with other values or expressions, which can be used like distinguish development environment and production environment in code.
|
145
146
|
|
146
|
-
|
147
147
|
For example, converts the expression `TWO` to `1 + 1`:
|
148
148
|
|
149
149
|
```ts
|