@modern-js/main-doc 2.21.1 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +42 -0
- package/docs/en/apis/app/commands.mdx +5 -5
- package/docs/en/apis/app/hooks/api/api.mdx +80 -0
- package/docs/en/apis/app/hooks/api/app.mdx +12 -0
- package/docs/en/apis/app/hooks/api/lambda.mdx +57 -0
- package/docs/en/apis/app/hooks/api/test.mdx +1 -1
- package/docs/en/apis/app/hooks/config/html.mdx +2 -2
- package/docs/en/apis/app/hooks/config/icon.mdx +19 -19
- package/docs/en/apis/app/hooks/config/mock.mdx +1 -1
- package/docs/en/apis/app/hooks/config/public.mdx +10 -10
- package/docs/en/apis/app/hooks/config/storybook.mdx +3 -3
- package/docs/en/apis/app/hooks/config/upload.mdx +13 -13
- package/docs/en/apis/app/hooks/modern-config.mdx +4 -4
- package/docs/en/apis/app/hooks/server/index_.mdx +2 -9
- package/docs/en/apis/app/hooks/server/test.mdx +5 -2
- package/docs/en/apis/app/hooks/shared.mdx +1 -1
- package/docs/en/apis/app/hooks/src/app.mdx +17 -27
- package/docs/en/apis/app/hooks/src/index_.mdx +6 -6
- package/docs/en/apis/app/hooks/src/pages.mdx +41 -37
- package/docs/en/apis/app/hooks/src/routes.mdx +16 -36
- package/docs/en/apis/app/hooks/src/server.mdx +1 -1
- package/docs/en/apis/app/hooks/src/stories.mdx +6 -3
- package/docs/en/apis/app/hooks/src/test.mdx +4 -3
- package/docs/en/apis/app/runtime/core/use-runtime-context.mdx +5 -1
- package/docs/en/apis/app/runtime/web-server/hook.mdx +2 -2
- package/docs/en/apis/app/runtime/web-server/middleware.mdx +2 -2
- package/docs/en/components/debug-app.mdx +1 -1
- package/docs/en/components/deploy.mdx +1 -0
- package/docs/en/components/entry-mode.mdx +0 -0
- package/docs/en/components/init-app.mdx +6 -10
- package/docs/en/components/init-rspack-app.mdx +4 -4
- package/docs/en/components/language-config.mdx +9 -0
- package/docs/en/components/package-manager.mdx +11 -0
- package/docs/en/components/release-note.mdx +1 -0
- package/docs/en/components/ua-polyfill.mdx +2 -2
- package/docs/en/configure/app/output/css-modules.mdx +13 -0
- package/docs/en/configure/app/source/config-dir.mdx +1 -1
- package/docs/en/configure/app/source/design-system.mdx +67 -67
- package/docs/en/configure/app/source/disable-default-entries.mdx +6 -5
- package/docs/en/configure/app/source/disable-entry-dirs.mdx +5 -5
- package/docs/en/configure/app/source/enable-async-entry.mdx +9 -9
- package/docs/en/configure/app/source/entries-dir.mdx +3 -3
- package/docs/en/configure/app/source/entries.mdx +21 -19
- package/docs/en/configure/app/tools/swc.mdx +2 -16
- package/docs/en/guides/advanced-features/bff/frameworks.mdx +2 -2
- package/docs/en/guides/advanced-features/bff/function.mdx +4 -4
- package/docs/en/guides/advanced-features/bff/type.mdx +5 -5
- package/docs/en/guides/advanced-features/rspack-start.mdx +7 -8
- package/docs/en/guides/advanced-features/ssg.mdx +2 -2
- package/docs/en/guides/advanced-features/testing.mdx +2 -2
- package/docs/en/guides/advanced-features/web-server.mdx +2 -2
- package/docs/en/guides/basic-features/css.mdx +2 -2
- package/docs/en/guides/basic-features/mock.mdx +1 -1
- package/docs/en/guides/basic-features/routes.mdx +11 -7
- package/docs/en/guides/concept/builder.mdx +15 -15
- package/docs/en/guides/concept/entries.mdx +50 -49
- package/docs/en/guides/get-started/glossary.mdx +12 -12
- package/docs/en/guides/get-started/introduction.mdx +17 -20
- package/docs/en/guides/get-started/quick-start.mdx +21 -37
- package/docs/en/guides/get-started/upgrade.mdx +15 -13
- package/docs/en/guides/topic-detail/changesets/_category_.json +4 -0
- package/docs/en/guides/topic-detail/changesets/add.mdx +125 -0
- package/docs/en/guides/topic-detail/changesets/changelog.mdx +238 -0
- package/docs/en/guides/topic-detail/changesets/commit.mdx +269 -0
- package/docs/en/guides/topic-detail/changesets/config.mdx +147 -0
- package/docs/en/guides/topic-detail/changesets/github.mdx +175 -0
- package/docs/en/guides/topic-detail/changesets/introduce.mdx +56 -0
- package/docs/en/guides/topic-detail/changesets/release-note.mdx +273 -0
- package/docs/en/guides/topic-detail/changesets/release-pre.mdx +49 -0
- package/docs/en/guides/topic-detail/changesets/release.mdx +229 -0
- package/docs/en/guides/topic-detail/generator/create/_category_.json +4 -0
- package/docs/en/guides/topic-detail/generator/create/config.mdx +75 -0
- package/docs/en/guides/topic-detail/generator/create/option.md +151 -0
- package/docs/en/guides/topic-detail/generator/create/use.mdx +66 -0
- package/docs/en/guides/topic-detail/generator/new/_category_.json +4 -0
- package/docs/en/guides/topic-detail/generator/new/config.md +155 -0
- package/docs/en/guides/topic-detail/generator/new/option.md +67 -0
- package/docs/en/guides/topic-detail/generator/new/use.md +95 -0
- package/docs/en/guides/topic-detail/generator/plugin/_category_.json +2 -2
- package/docs/en/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
- package/docs/en/guides/topic-detail/generator/plugin/api/afterForged.md +49 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/context.md +184 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/input.md +124 -0
- package/docs/en/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
- package/docs/en/guides/topic-detail/generator/plugin/category.md +88 -0
- package/docs/en/guides/topic-detail/generator/plugin/context.md +104 -0
- package/docs/en/guides/topic-detail/generator/plugin/structure.md +106 -0
- package/docs/en/guides/topic-detail/generator/plugin/use.md +33 -0
- package/docs/en/guides/topic-detail/micro-frontend/c02-development.mdx +8 -8
- package/docs/en/guides/troubleshooting/builder.mdx +8 -0
- package/docs/en/tutorials/first-app/c03-css.mdx +2 -2
- package/docs/en/tutorials/first-app/c08-entries.mdx +3 -3
- package/docs/zh/apis/app/commands.mdx +3 -3
- package/docs/zh/apis/app/hooks/api/{functions/api.mdx → api.mdx} +4 -4
- package/docs/zh/apis/app/hooks/api/app.mdx +12 -0
- package/docs/zh/apis/app/hooks/api/{framework/lambda.mdx → lambda.mdx} +5 -5
- package/docs/zh/apis/app/hooks/api/test.mdx +3 -3
- package/docs/zh/apis/app/hooks/config/icon.mdx +15 -15
- package/docs/zh/apis/app/hooks/config/mock.mdx +1 -1
- package/docs/zh/apis/app/hooks/config/public.mdx +3 -3
- package/docs/zh/apis/app/hooks/config/upload.mdx +1 -1
- package/docs/zh/apis/app/hooks/modern-config.mdx +3 -3
- package/docs/zh/apis/app/hooks/server/index_.mdx +1 -6
- package/docs/zh/apis/app/hooks/shared.mdx +1 -1
- package/docs/zh/apis/app/hooks/src/app.mdx +15 -25
- package/docs/zh/apis/app/hooks/src/index_.mdx +6 -6
- package/docs/zh/apis/app/hooks/src/pages.mdx +7 -3
- package/docs/zh/apis/app/hooks/src/routes.mdx +4 -4
- package/docs/zh/apis/app/hooks/src/stories.mdx +1 -1
- package/docs/zh/apis/app/runtime/core/use-runtime-context.mdx +5 -1
- package/docs/zh/community/blog/v2-release-note.mdx +1 -1
- package/docs/zh/community/contributing-guide.mdx +1 -1
- package/docs/zh/components/entry-mode.mdx +0 -0
- package/docs/zh/components/init-app.mdx +5 -9
- package/docs/zh/components/language-config.mdx +9 -0
- package/docs/zh/components/package-manager.mdx +11 -0
- package/docs/zh/components/ua-polyfill.mdx +1 -1
- package/docs/zh/configure/app/output/css-modules.mdx +13 -0
- package/docs/zh/configure/app/source/design-system.mdx +3 -4
- package/docs/zh/configure/app/source/enable-async-entry.mdx +2 -5
- package/docs/zh/configure/app/source/entries.mdx +2 -2
- package/docs/zh/configure/app/tools/swc.mdx +2 -16
- package/docs/zh/guides/advanced-features/rspack-start.mdx +7 -8
- package/docs/zh/guides/advanced-features/ssg.mdx +1 -1
- package/docs/zh/guides/advanced-features/testing.mdx +2 -2
- package/docs/zh/guides/advanced-features/web-server.mdx +1 -1
- package/docs/zh/guides/basic-features/css.mdx +1 -1
- package/docs/zh/guides/basic-features/mock.mdx +1 -1
- package/docs/zh/guides/basic-features/routes.mdx +7 -4
- package/docs/zh/guides/concept/builder.mdx +1 -1
- package/docs/zh/guides/concept/entries.mdx +21 -17
- package/docs/zh/guides/get-started/quick-start.mdx +7 -10
- package/docs/zh/guides/get-started/upgrade.mdx +1 -1
- package/docs/zh/guides/topic-detail/changesets/add.mdx +15 -13
- package/docs/zh/guides/topic-detail/changesets/changelog.mdx +20 -20
- package/docs/zh/guides/topic-detail/changesets/commit.mdx +12 -14
- package/docs/zh/guides/topic-detail/changesets/config.mdx +5 -5
- package/docs/zh/guides/topic-detail/changesets/github.mdx +38 -27
- package/docs/zh/guides/topic-detail/changesets/introduce.mdx +12 -12
- package/docs/zh/guides/topic-detail/changesets/release-note.mdx +84 -70
- package/docs/zh/guides/topic-detail/changesets/release-pre.mdx +9 -9
- package/docs/zh/guides/topic-detail/changesets/release.mdx +29 -29
- package/docs/zh/guides/topic-detail/generator/create/_category_.json +4 -0
- package/docs/zh/guides/topic-detail/generator/create/config.mdx +76 -0
- package/docs/zh/guides/topic-detail/generator/create/option.md +151 -0
- package/docs/zh/guides/topic-detail/generator/create/use.mdx +66 -0
- package/docs/zh/guides/topic-detail/generator/new/_category_.json +4 -0
- package/docs/zh/guides/topic-detail/generator/new/config.md +153 -0
- package/docs/zh/guides/topic-detail/generator/new/option.md +67 -0
- package/docs/zh/guides/topic-detail/generator/new/use.md +94 -0
- package/docs/zh/guides/topic-detail/generator/plugin/_category_.json +2 -2
- package/docs/zh/guides/topic-detail/generator/plugin/api/_category_.json +1 -1
- package/docs/zh/guides/topic-detail/generator/plugin/api/afterForged.md +50 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/context.md +184 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/input.md +124 -0
- package/docs/zh/guides/topic-detail/generator/plugin/api/onForged.md +310 -0
- package/docs/zh/guides/topic-detail/generator/plugin/category.md +93 -0
- package/docs/zh/guides/topic-detail/generator/plugin/context.md +105 -0
- package/docs/zh/guides/topic-detail/generator/plugin/structure.md +106 -0
- package/docs/zh/guides/topic-detail/generator/plugin/use.md +33 -0
- package/docs/zh/guides/topic-detail/micro-frontend/c02-development.mdx +4 -4
- package/docs/zh/guides/topic-detail/model/test-model.mdx +1 -1
- package/docs/zh/guides/troubleshooting/builder.mdx +8 -0
- package/docs/zh/tutorials/first-app/c03-css.mdx +1 -1
- package/docs/zh/tutorials/first-app/c08-entries.mdx +1 -1
- package/package.json +5 -5
- package/docs/en/apis/app/hooks/api/framework/_category_.json +0 -4
- package/docs/en/apis/app/hooks/api/framework/lambda.mdx +0 -57
- package/docs/en/apis/app/hooks/api/functions/_category_.json +0 -4
- package/docs/en/apis/app/hooks/api/functions/api.mdx +0 -81
- package/docs/en/apis/app/hooks/api/functions/app.mdx +0 -12
- package/docs/en/apis/app/hooks/api/functions/common.mdx +0 -9
- package/docs/en/guides/topic-detail/generator/codesmith/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
- package/docs/en/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
- package/docs/en/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
- package/docs/en/guides/topic-detail/generator/codesmith/api/git.mdx +0 -50
- package/docs/en/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -57
- package/docs/en/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
- package/docs/en/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -48
- package/docs/en/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
- package/docs/en/guides/topic-detail/generator/codesmith/introduce.mdx +0 -47
- package/docs/en/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
- package/docs/en/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
- package/docs/en/guides/topic-detail/generator/config/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/config/app.mdx +0 -82
- package/docs/en/guides/topic-detail/generator/config/common.mdx +0 -100
- package/docs/en/guides/topic-detail/generator/config/module.mdx +0 -42
- package/docs/en/guides/topic-detail/generator/config/monorepo.mdx +0 -28
- package/docs/en/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
- package/docs/en/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -58
- package/docs/en/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
- package/docs/en/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
- package/docs/en/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
- package/docs/en/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
- package/docs/en/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
- package/docs/en/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
- package/docs/en/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
- package/docs/en/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
- package/docs/en/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
- package/docs/en/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
- package/docs/en/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -55
- package/docs/en/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -55
- package/docs/en/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
- package/docs/en/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -31
- package/docs/en/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
- package/docs/en/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -90
- package/docs/en/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
- package/docs/en/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
- package/docs/en/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
- package/docs/en/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
- package/docs/en/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
- package/docs/en/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -18
- package/docs/en/guides/topic-detail/generator/plugin/develop.mdx +0 -125
- package/docs/en/guides/topic-detail/generator/plugin/use.mdx +0 -61
- package/docs/en/guides/topic-detail/generator/project.mdx +0 -118
- package/docs/zh/apis/app/hooks/api/framework/_category_.json +0 -4
- package/docs/zh/apis/app/hooks/api/functions/_category_.json +0 -4
- package/docs/zh/apis/app/hooks/api/functions/app.mdx +0 -12
- package/docs/zh/apis/app/hooks/api/functions/common.mdx +0 -9
- package/docs/zh/guides/topic-detail/generator/codesmith/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/codesmith/api/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/codesmith/api/app.mdx +0 -152
- package/docs/zh/guides/topic-detail/generator/codesmith/api/ejs.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/fs.mdx +0 -54
- package/docs/zh/guides/topic-detail/generator/codesmith/api/git.mdx +0 -49
- package/docs/zh/guides/topic-detail/generator/codesmith/api/handlebars.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/json.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/codesmith/api/npm.mdx +0 -47
- package/docs/zh/guides/topic-detail/generator/codesmith/develop.mdx +0 -53
- package/docs/zh/guides/topic-detail/generator/codesmith/introduce.mdx +0 -59
- package/docs/zh/guides/topic-detail/generator/codesmith/run-in-js.mdx +0 -47
- package/docs/zh/guides/topic-detail/generator/codesmith/structure.mdx +0 -89
- package/docs/zh/guides/topic-detail/generator/config/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/config/app.mdx +0 -82
- package/docs/zh/guides/topic-detail/generator/config/common.mdx +0 -100
- package/docs/zh/guides/topic-detail/generator/config/module.mdx +0 -42
- package/docs/zh/guides/topic-detail/generator/config/monorepo.mdx +0 -28
- package/docs/zh/guides/topic-detail/generator/plugin/abstract.mdx +0 -23
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addFile.mdx +0 -52
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addHelper.mdx +0 -26
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addManyFile.mdx +0 -55
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/addPartial.mdx +0 -26
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/introduce.mdx +0 -39
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmDir.mdx +0 -24
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/rmFile.mdx +0 -24
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateJSONFile.mdx +0 -54
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateModernConfig.mdx +0 -27
- package/docs/zh/guides/topic-detail/generator/plugin/api/file/updateTextRawFile.mdx +0 -33
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/gitAddAndCommit.mdx +0 -20
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/initGitRepo.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/api/git/isInGitRepo.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/afterForged.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/hook/onForged.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/isFileExit.mdx +0 -22
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/locale.mdx +0 -17
- package/docs/zh/guides/topic-detail/generator/plugin/api/info/readDir.mdx +0 -22
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputAfter.mdx +0 -57
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/addInputBefore.mdx +0 -56
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInput.mdx +0 -43
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/setInputValue.mdx +0 -29
- package/docs/zh/guides/topic-detail/generator/plugin/api/input/type.mdx +0 -65
- package/docs/zh/guides/topic-detail/generator/plugin/api/introduce.mdx +0 -92
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/createElement.mdx +0 -33
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/createSubProject.mdx +0 -35
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/enableFunc.mdx +0 -44
- package/docs/zh/guides/topic-detail/generator/plugin/api/new/introduce.mdx +0 -15
- package/docs/zh/guides/topic-detail/generator/plugin/api/npm/_category_.json +0 -4
- package/docs/zh/guides/topic-detail/generator/plugin/api/npm/install.mdx +0 -16
- package/docs/zh/guides/topic-detail/generator/plugin/develop.mdx +0 -125
- package/docs/zh/guides/topic-detail/generator/plugin/use.mdx +0 -61
- package/docs/zh/guides/topic-detail/generator/project.mdx +0 -118
@@ -0,0 +1,104 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 4
|
3
|
+
---
|
4
|
+
|
5
|
+
# Context
|
6
|
+
|
7
|
+
By default, generator plugins will export a function that takes `context` as a parameter. During execution, `context` will be automatically injected into the generator plugin.
|
8
|
+
|
9
|
+
```ts title="src/index.ts"
|
10
|
+
import { IPluginContext, ForgedAPI } from '@modern-js/generator-plugin';
|
11
|
+
|
12
|
+
export default function (context: IPluginContext) {
|
13
|
+
context.onForged(async (_api: ForgedAPI, _input: Record<string, unknown>) => {
|
14
|
+
/**
|
15
|
+
* Todo
|
16
|
+
*/
|
17
|
+
});
|
18
|
+
}
|
19
|
+
```
|
20
|
+
`context` provides two types of APIs, which are used to customize input and define generator plugin lifecycle logic.
|
21
|
+
|
22
|
+
:::info
|
23
|
+
Only some APIs are briefly explained below. For the complete API, please refer to [Generator Plugin API](/guides/topic-detail/generator/plugin/api/context.html).
|
24
|
+
:::
|
25
|
+
|
26
|
+
## Customize Input
|
27
|
+
|
28
|
+
Both Modern.js Web App and Npm Module schemes have default input interactions. These APIs can be used to add, modify, hide, and provide default values for these inputs.
|
29
|
+
|
30
|
+
For example:
|
31
|
+
|
32
|
+
- Add question
|
33
|
+
|
34
|
+
```ts
|
35
|
+
context.addInputBefore('packageManager', {
|
36
|
+
type: 'object',
|
37
|
+
properties: {
|
38
|
+
'username': {
|
39
|
+
type: 'string',
|
40
|
+
title: '用户名',
|
41
|
+
},
|
42
|
+
},
|
43
|
+
});
|
44
|
+
```
|
45
|
+
|
46
|
+
- Hide question by setting `config`
|
47
|
+
|
48
|
+
```ts
|
49
|
+
context.setDefaultConfig({ langauge: 'ts' });
|
50
|
+
```
|
51
|
+
|
52
|
+
## Lifecycle
|
53
|
+
|
54
|
+
Generator plugin provide two lifecycle hooks to define generator plugin behavior:
|
55
|
+
|
56
|
+
- `onForged`: Lifecycle after file operations are completed.
|
57
|
+
|
58
|
+
- `afterForged`: Lifecycle after the `onForged` hook function is executed.
|
59
|
+
|
60
|
+
## `onForged`
|
61
|
+
|
62
|
+
Hook function after the Modern.js project scheme generator has completed file operations. It is used to complete file operations in the generator plugin, such as adding template files, overwriting existing files, deleting existing files, etc.
|
63
|
+
|
64
|
+
When multiple generator plugins are executed simultaneously for extension type, the `onForged` operations of the corresponding generator plugins will be executed in order according to the declared order.
|
65
|
+
|
66
|
+
The `onForged` function takes a callback function as a parameter, with `api` and `input` as arguments.
|
67
|
+
|
68
|
+
```ts
|
69
|
+
context.onForged(async (api: ForgedAPI, input: Record<string, unknown>) => {
|
70
|
+
const { language } = input;
|
71
|
+
api.addFile({
|
72
|
+
type: FileType.Text,
|
73
|
+
file: `src/index.${language as string}`,
|
74
|
+
templateFile: `index.${language as string}.handlebars`,
|
75
|
+
force: true,
|
76
|
+
});
|
77
|
+
})
|
78
|
+
```
|
79
|
+
|
80
|
+
The `api` object provides file operation-related methods supported by generator plugin.
|
81
|
+
|
82
|
+
`input` is the current user input, which includes the `--config` parameter definition, the default scheme interaction, and the user input defined by the generator plugin.
|
83
|
+
|
84
|
+
When adding a new file template, define the template file in the `templates` directory, and then operate on it through the `api` method above. The generator plugin defaults to operating on files in the `templates` directory, so there is no need to declare the `templates` path.
|
85
|
+
|
86
|
+
## `afterForged`
|
87
|
+
|
88
|
+
Executed after the `onForged` hook function is completed. It is mainly used to install dependencies, perform git operations, etc.
|
89
|
+
|
90
|
+
By default, Modern.js project scheme will install dependencies and initialize Git after completing file operations, and perform git initial submissions, etc. This hook function can be omitted.
|
91
|
+
|
92
|
+
For custom generator plugins that also support the `custom` type, which only provides a small number of best practice project configurations, installation of dependencies and Git initialization operations need to be completed in this hook function.
|
93
|
+
|
94
|
+
The `afterForged` function also takes a callback function as a parameter, with `api` and `input` as arguments.
|
95
|
+
|
96
|
+
```ts
|
97
|
+
context.afterForged(
|
98
|
+
async (api: AfterForgedAPI, input: Record<string, unknown>) => {
|
99
|
+
const { packageManager } = input;
|
100
|
+
console.info('packageManager:', packageManager);
|
101
|
+
await api.install();
|
102
|
+
},
|
103
|
+
);
|
104
|
+
```
|
@@ -0,0 +1,106 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 1
|
3
|
+
---
|
4
|
+
|
5
|
+
# Introduction and Project Creation
|
6
|
+
|
7
|
+
## Introduction
|
8
|
+
|
9
|
+
Modern.js provides engineering solutions such as Web App and Npm Module. By using the `@modern-js/create` tool, you can create initial project templates for engineering solutions. The initial project template provides a basic code development environment, simple example code, and configuration, etc.
|
10
|
+
|
11
|
+
The initial templates provided by Modern.js are generic and can meet some common project development needs.
|
12
|
+
|
13
|
+
When you use Modern.js deeply, you will inevitably find that each created project will make some specific similar changes for its own project, such as modifying example code, adding some configurations, enabling certain features, etc.
|
14
|
+
|
15
|
+
Generator plugin can help you to deposit these specific changes for individuals or teams. When running `npx @modern-js/create@latest`, you only need to simply add the `--plugin` parameter to avoid repetitive modification of the project after each project creation.
|
16
|
+
|
17
|
+
Generator plugin is based on the initial template projects provided by Modern.js, providing methods to add, delete, and modify templates, and modifying `package.json`, `modernConfig` configurations, and enabling features through a convenient way.
|
18
|
+
|
19
|
+
## Create Project
|
20
|
+
|
21
|
+
Use `@modern-js/create` to create a generator plugin project directly:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
npx @modern-js/create@latest plugin --plugin @modern-js/generator-plugin-plugin
|
25
|
+
? Please select the type of project you want to create: Npm Module
|
26
|
+
? Please select the project scenario: Generator Plugin
|
27
|
+
? Please fill in the package name of the generator plugin: plugin
|
28
|
+
? Please select the programming language: TS
|
29
|
+
? Please select the package manager: pnpm
|
30
|
+
? Please select the type of plugin: extend
|
31
|
+
? Please select the base type of the plugin: Web App
|
32
|
+
```
|
33
|
+
|
34
|
+
After creating, we can take a look at the directory structure of this project:
|
35
|
+
|
36
|
+
```bash
|
37
|
+
.
|
38
|
+
├── .changeset
|
39
|
+
│ └── config.json
|
40
|
+
├── .eslintrc.js
|
41
|
+
├── .gitignore
|
42
|
+
├── .npmrc
|
43
|
+
├── .nvmrc
|
44
|
+
├── .prettierrc
|
45
|
+
├── README.md
|
46
|
+
├── modern.config.ts
|
47
|
+
├── package.json
|
48
|
+
├── src
|
49
|
+
│ ├── modern-app-env.d.ts
|
50
|
+
│ └── index.ts
|
51
|
+
├── templates
|
52
|
+
│ └── .gitkeep
|
53
|
+
└── tsconfig.json
|
54
|
+
```
|
55
|
+
|
56
|
+
The project is based on the Npm module project, and the core files are as follows:
|
57
|
+
|
58
|
+
```bash
|
59
|
+
*
|
60
|
+
├── package.json
|
61
|
+
├── src
|
62
|
+
│ └── index.ts
|
63
|
+
├── templates
|
64
|
+
│ └── .gitkeep
|
65
|
+
```
|
66
|
+
|
67
|
+
## package.json
|
68
|
+
|
69
|
+
In addition to the normal fields of a module project, `package.json` provides a `meta` field to describe information about the generator plugin.
|
70
|
+
|
71
|
+
Generator plugin is divided into two categories: extension and custom. For specific classification definitions, please refer to [Type](/guides/topic-detail/generator/plugin/category).
|
72
|
+
|
73
|
+
```json title="package.json"
|
74
|
+
{
|
75
|
+
...,
|
76
|
+
"meta": {
|
77
|
+
"extend": "mwa"
|
78
|
+
}
|
79
|
+
}
|
80
|
+
```
|
81
|
+
|
82
|
+
## src/index.ts
|
83
|
+
|
84
|
+
This file is used to complete the content development of the generator plugin.
|
85
|
+
|
86
|
+
```js
|
87
|
+
import { IPluginContext, ForgedAPI } from '@modern-js/generator-plugin';
|
88
|
+
|
89
|
+
export default function (context: IPluginContext) {
|
90
|
+
context.onForged(async (_api: ForgedAPI, _input: Record<string, unknown>) => {
|
91
|
+
/**
|
92
|
+
* todo
|
93
|
+
*/
|
94
|
+
});
|
95
|
+
}
|
96
|
+
```
|
97
|
+
|
98
|
+
This file exports a function by default, and the function takes `context` as a parameter. The `context` object provides API methods supported by the generator plugin, which can be used to implement the logic of the generator plugin. The capabilities provided by `context` can be found in [context](/guides/topic-detail/generator/plugin/context).
|
99
|
+
|
100
|
+
## templates
|
101
|
+
|
102
|
+
The `templates` directory contains template files for the current customization method, supporting [Handlebars](https://handlebarsjs.com/) and [EJS](https://ejs.co/) formats. Different rendering engines will be used for rendering according to the template file suffix. If there is no suffix, the template file will be copied directly to the target directory.
|
103
|
+
|
104
|
+
If the template file is a `js`, `ts`, or `json` file, it is recommended to use the `.handlebars` or `.ejs` suffix directly to avoid project eslint errors and recognition issues in Monorepo projects.
|
105
|
+
|
106
|
+
The `.gitignore` and `.npmrc` files in the template will be automatically deleted when publishing the npm package, so it is necessary to use the `.handlebars` or `.ejs` suffix to keep them.
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
sidebar_position: 3
|
3
|
+
---
|
4
|
+
|
5
|
+
# Usage
|
6
|
+
|
7
|
+
`@modern-js/create` provides the `--plugin` parameter to run the generator plugin project.
|
8
|
+
|
9
|
+
`--plugin` supports three formats:
|
10
|
+
|
11
|
+
## Absolute path
|
12
|
+
|
13
|
+
Suitable for local development and debugging. After development is completed, build the project by running `npm run build` in the generator plugin project, and then use the following command for testing:
|
14
|
+
|
15
|
+
```bash
|
16
|
+
npx @modern-js/create@latest --plugin <pluginPath>
|
17
|
+
```
|
18
|
+
|
19
|
+
## Relative path
|
20
|
+
|
21
|
+
Suitable for local development and debugging or when the generator plugin project and the target project to be created are in the same Monorepo and there is no need to publish an NPM package. After building the generator plugin project, use the following command:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
npx @modern-js/create@latest --plugin file:../<pluginPath>
|
25
|
+
```
|
26
|
+
|
27
|
+
## NPM package
|
28
|
+
|
29
|
+
Suitable for scenarios where the generator project is published on npm for sharing.
|
30
|
+
|
31
|
+
```bash
|
32
|
+
npx @modern-js/create@latest --plugin <pluginPackage>
|
33
|
+
```
|
@@ -33,8 +33,8 @@ npx @modern-js/create@latest
|
|
33
33
|
After the project is created, we can enable the `micro frontend` through `pnpm run new`:
|
34
34
|
|
35
35
|
```bash
|
36
|
-
?
|
37
|
-
?
|
36
|
+
? Please select the operation you want: Enable features
|
37
|
+
? Please select the feature name: Enable Micro Front-end Feature
|
38
38
|
```
|
39
39
|
|
40
40
|
Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
|
@@ -115,8 +115,8 @@ npx @modern-js/create@latest
|
|
115
115
|
After the project is created, we can enable the `micro frontend` function through `pnpm run new`:
|
116
116
|
|
117
117
|
```bash
|
118
|
-
?
|
119
|
-
?
|
118
|
+
? Please select the operation you want: Enable features
|
119
|
+
? Please select the feature name: Enable Micro Front-end Feature
|
120
120
|
```
|
121
121
|
|
122
122
|
Next, let's register the micro frontend plugin and add the main micro frontend app and add the list of sub-apps:
|
@@ -143,8 +143,8 @@ npx @modern-js/create@latest
|
|
143
143
|
After create sub-app. We execute `pnpm run new` to enable the `micro frontend` function:
|
144
144
|
|
145
145
|
```bash
|
146
|
-
?
|
147
|
-
?
|
146
|
+
? Please select the operation you want: Enable features
|
147
|
+
? Please select the feature name: Enable Micro Front-end Feature
|
148
148
|
```
|
149
149
|
|
150
150
|
Next, let's register the micro frontend plugin and modify `modern.config.ts` to add the configuration of the micro frontend sub-app `deploy.microFrontend`:
|
@@ -192,8 +192,8 @@ npx @modern-js/create@latest
|
|
192
192
|
After create sub-app. We execute `pnpm run new` to enable the `micro frontend` function:
|
193
193
|
|
194
194
|
```bash
|
195
|
-
?
|
196
|
-
?
|
195
|
+
? Please select the operation you want: Enable features
|
196
|
+
? Please select the feature name: Enable Micro Front-end Feature
|
197
197
|
```
|
198
198
|
|
199
199
|
Next, let's register the micro frontend plugin and modify `modern.config.ts` to add the configuration of the micro frontend sub-app `deploy.microFrontend`:
|
@@ -29,3 +29,11 @@ Please refer to [Modern.js Builder - Exceptions FAQ](https://modernjs.dev/builde
|
|
29
29
|
- 'compilation' argument error when webpack compiling?
|
30
30
|
- Compile error `You may need additional loader`?
|
31
31
|
- Find `exports is not defined` runtime error?
|
32
|
+
|
33
|
+
## HMR FAQ
|
34
|
+
|
35
|
+
Please refer to [Modern.js Builder - HMR FAQ](https://modernjs.dev/builder/guide/faq/hmr.html), such as:
|
36
|
+
|
37
|
+
- HMR not working when external React?
|
38
|
+
- HMR not working when setting filename hash in development mode?
|
39
|
+
- HMR not working when updating React components?
|
@@ -114,8 +114,8 @@ Modern.js integrates the mainstream, light, general-purpose Utility Class librar
|
|
114
114
|
Execute `pnpm run new` and select the following to start Tailwind CSS:
|
115
115
|
|
116
116
|
```bash
|
117
|
-
?
|
118
|
-
?
|
117
|
+
? Please select the operation you want: Enable features
|
118
|
+
? Please select the feature name: Enable Tailwind CSS
|
119
119
|
```
|
120
120
|
|
121
121
|
Register the Tailwind plugin in `modern.config.ts`:
|
@@ -14,9 +14,9 @@ A complete project may require multiple entries, Modern.js supports the automati
|
|
14
14
|
We can also use it to create new project elements and execute `pnpm run new` in the project root directory:
|
15
15
|
|
16
16
|
```bash
|
17
|
-
?
|
18
|
-
?
|
19
|
-
?
|
17
|
+
? Please select the operation you want: Create Element
|
18
|
+
? Please select the type of element to create: New "entry"
|
19
|
+
? Please fill in the entry name: landing-page
|
20
20
|
```
|
21
21
|
|
22
22
|
When created, the project will look like this:
|
@@ -126,7 +126,7 @@ Options:
|
|
126
126
|
```bash
|
127
127
|
$ npx modern new
|
128
128
|
? 请选择你想要的操作 创建工程元素
|
129
|
-
?
|
129
|
+
? 请选择创建元素类型 新建「应用入口」
|
130
130
|
? 请填写入口名称 entry
|
131
131
|
```
|
132
132
|
|
@@ -137,8 +137,8 @@ $ npx modern new
|
|
137
137
|
```bash
|
138
138
|
$ npx modern new
|
139
139
|
? 请选择你想要的操作 启用可选功能
|
140
|
-
?
|
141
|
-
❯ 启用 Tailwind CSS 支持
|
140
|
+
? 请选择功能名称 (Use arrow keys)
|
141
|
+
❯ 启用 「Tailwind CSS」 支持
|
142
142
|
启用「BFF」功能
|
143
143
|
启用「微前端」模式
|
144
144
|
启用「单元测试 / 集成测试」功能
|
@@ -4,7 +4,7 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# **/*.[tj]s
|
6
6
|
|
7
|
-
在 BFF
|
7
|
+
在 [BFF 函数写法](/guides/advanced-features/bff/type.html#函数写法)下,声明 API 路由的文件。除了[某些约定文件](/apis/app/hooks/api/api#白名单)外,`api` 目录下的文件会被注册为接口的路由。
|
8
8
|
|
9
9
|
:::info
|
10
10
|
使用 `api` 目录需要开启 BFF 功能,需要在项目下执行 new 命令启用「BFF」功能。
|
@@ -31,7 +31,7 @@ sidebar_position: 1
|
|
31
31
|
|
32
32
|
### 动态路由
|
33
33
|
|
34
|
-
|
34
|
+
路由系统支持通过 `[]` 命名的文件目录生成动态路由。
|
35
35
|
|
36
36
|
- `api/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
|
37
37
|
- `api/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
|
@@ -64,7 +64,7 @@ export const get = async () => {
|
|
64
64
|
};
|
65
65
|
```
|
66
66
|
|
67
|
-
这样导出函数,则会得到一个 `
|
67
|
+
这样导出函数,则会得到一个 `GET` 接口。
|
68
68
|
|
69
69
|
应用工程中支持了 9 个 Method 定义,即:`GET`、`POST`、`PUT`、`DELETE`、`CONNECT`、`TRACE`、`PATCH`、`OPTION`、`HEAD`,即可以用这些 Method 作为函数导出的名字。
|
70
70
|
|
@@ -75,6 +75,6 @@ export const get = async () => {
|
|
75
75
|
可以在一个文件中定义多个不同 Method 的函数,但如果定义多个相同 Method 的函数,则只有第一个会生效。
|
76
76
|
|
77
77
|
:::info
|
78
|
-
|
78
|
+
需要注意的是,定义的函数都应该是异步的,这个与函数调用时类型有关。
|
79
79
|
|
80
80
|
:::
|
@@ -1,10 +1,10 @@
|
|
1
1
|
---
|
2
2
|
title: lambda/*.[tj]s
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 3
|
4
4
|
---
|
5
5
|
# lambda/*.[tj]s
|
6
6
|
|
7
|
-
在 BFF
|
7
|
+
在 [BFF 框架写法](/guides/advanced-features/bff/type.html#框架写法)下,声明 API 路由的文件。除了[某些约定文件](/apis/app/hooks/api/lambda#白名单)外,`lambda/` 目录下的文件会被注册为接口的路由。
|
8
8
|
|
9
9
|
:::info
|
10
10
|
使用 `api` 目录需要开启 BFF 功能,需要在项目下执行 new 命令启用「BFF」功能。
|
@@ -34,7 +34,7 @@ sidebar_position: 1
|
|
34
34
|
|
35
35
|
### 动态路由
|
36
36
|
|
37
|
-
|
37
|
+
路由系统支持通过 `[]` 命名的文件目录生成动态路由。
|
38
38
|
|
39
39
|
- `api/lambda/user/[username]/info.ts` -> `$BASENAME/user/:username/info`
|
40
40
|
- `api/lambda/user/[username]/delete.ts` -> `$BASENAME/user/:username/delete`
|
@@ -44,7 +44,7 @@ sidebar_position: 1
|
|
44
44
|
|
45
45
|
### 白名单
|
46
46
|
|
47
|
-
默认 `
|
47
|
+
默认 `lambda` 目录下所有文件都会当作 BFF 函数文件去解析,但同样我们也设置了白名单,这些文件不被被解析:
|
48
48
|
|
49
49
|
- 命名以 `_` 开头的文件。例如:`_utils.ts`。
|
50
50
|
- 命名以 `_` 开头的文件夹下所有文件。例如:`_utils/index.ts`、`_utils/cp.ts`。
|
@@ -54,4 +54,4 @@ sidebar_position: 1
|
|
54
54
|
|
55
55
|
## 函数定义
|
56
56
|
|
57
|
-
和函数写法下[函数定义](/apis/app/hooks/api/
|
57
|
+
和函数写法下[函数定义](/apis/app/hooks/api/api#函数定义)完全一致。
|
@@ -1,12 +1,12 @@
|
|
1
1
|
---
|
2
2
|
title: test.[tj]s
|
3
|
-
sidebar_position:
|
3
|
+
sidebar_position: 4
|
4
4
|
---
|
5
5
|
# test.[tj]s
|
6
6
|
|
7
|
-
|
7
|
+
The BFF test file of the application supports writing test cases in files with the suffix `.test.[tj]sx?` under the `api/` directory.
|
8
8
|
|
9
9
|
:::info
|
10
|
-
|
10
|
+
Enabling unit testing and integration testing requires running the new command to enable the "Unit Testing/Integration Testing" function under the project first.
|
11
11
|
|
12
12
|
:::
|
@@ -1,11 +1,11 @@
|
|
1
1
|
---
|
2
|
-
title: icon
|
2
|
+
title: icon/
|
3
3
|
sidebar_position: 2
|
4
4
|
---
|
5
5
|
|
6
|
-
#
|
6
|
+
# icon/
|
7
7
|
|
8
|
-
##
|
8
|
+
## Favicon
|
9
9
|
|
10
10
|
当项目根目录的 `config` 目录下存在 `favicon.*` 文件时,Modern.js 会自动将该文件设置到 [html.favicon](/configure/app/html/favicon) 配置项中,用于生成页面的 favicon 图标:
|
11
11
|
|
@@ -24,15 +24,15 @@ sidebar_position: 2
|
|
24
24
|
|
25
25
|
在设置 app icon 时,Modern.js 会按以下顺序寻找文件:
|
26
26
|
|
27
|
-
- favicon.png
|
28
|
-
- favicon.jpg
|
29
|
-
- favicon.jpeg
|
30
|
-
- favicon.svg
|
31
|
-
- favicon.ico
|
27
|
+
- `favicon.png`
|
28
|
+
- `favicon.jpg`
|
29
|
+
- `favicon.jpeg`
|
30
|
+
- `favicon.svg`
|
31
|
+
- `favicon.ico`
|
32
32
|
|
33
|
-
##
|
33
|
+
## Apple Touch Icon
|
34
34
|
|
35
|
-
当项目根目录的 `config` 目录下存在 `icon.*` 文件时,Modern.js 会自动将该文件设置到 [html.appIcon](/configure/app/html/app-icon) 配置项中,用于生成 iOS 系统下的
|
35
|
+
当项目根目录的 `config` 目录下存在 `icon.*` 文件时,Modern.js 会自动将该文件设置到 [html.appIcon](/configure/app/html/app-icon) 配置项中,用于生成 iOS 系统下的 Apple Touch Icon 图标。
|
36
36
|
|
37
37
|
```
|
38
38
|
./config
|
@@ -49,8 +49,8 @@ sidebar_position: 2
|
|
49
49
|
|
50
50
|
在设置 app icon 时,Modern.js 会按以下顺序寻找文件:
|
51
51
|
|
52
|
-
- icon.png
|
53
|
-
- icon.jpg
|
54
|
-
- icon.jpeg
|
55
|
-
- icon.svg
|
56
|
-
- icon.ico
|
52
|
+
- `icon.png`
|
53
|
+
- `icon.jpg`
|
54
|
+
- `icon.jpeg`
|
55
|
+
- `icon.svg`
|
56
|
+
- `icon.ico`
|
@@ -4,13 +4,13 @@ sidebar_position: 3
|
|
4
4
|
---
|
5
5
|
# public/
|
6
6
|
|
7
|
-
`public/`
|
7
|
+
`public/` 目录中可以放置任意格式的静态资源文件,文件会被服务端部署到对应的应用域名下。
|
8
8
|
|
9
9
|
## 说明
|
10
10
|
|
11
|
-
|
11
|
+
文件路由基于目录结构的约定,其中,`public/` 为根目录,对应 Web 应用根路径。
|
12
12
|
|
13
|
-
例如 `config/public/sdk/index.js`
|
13
|
+
例如 `config/public/sdk/index.js` 文件,在部署后将会被部署在 `${domain}/sdk/index.js` 下。
|
14
14
|
|
15
15
|
## 场景
|
16
16
|
|
@@ -1,9 +1,9 @@
|
|
1
1
|
---
|
2
|
-
title: modern.config.
|
2
|
+
title: modern.config.[tj]s
|
3
3
|
sidebar_position: 8
|
4
4
|
---
|
5
|
-
# modern.config.
|
5
|
+
# modern.config.[tj]s
|
6
6
|
|
7
7
|
Modern.js 配置文件, 通过该文件可以对当前项目的各个方面进行个性化配置。
|
8
8
|
|
9
|
-
了解配置的具体用法,请参考
|
9
|
+
了解配置的具体用法,请参考[配置使用](/configure/app/usage)。
|
@@ -4,11 +4,6 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# index.[tj]s
|
6
6
|
|
7
|
-
扩展 Modern.js Web Server 的文件,在此文件中可以给应用工程启动的 Web Server 添加 Hook 或 Middleware。
|
7
|
+
扩展 Modern.js Web Server 的文件,在此文件中可以给应用工程启动的 Web Server 添加 [Hook](/apis/app/runtime/web-server/hook) 或 [Middleware](/apis/app/runtime/web-server/middleware)。
|
8
8
|
|
9
9
|
可以对请求和响应进行拦截处理,鉴权与角色、请求预处理、异常兜底等。也可在内置处理逻辑(包括路由匹配、资源寻址、头部注入、页面渲染,静态 Web 托管)插入特定的业务逻辑。
|
10
|
-
|
11
|
-
:::info
|
12
|
-
具体使用示例可查看 [Hook](/apis/app/runtime/web-server/hook) & [Middleware](/apis/app/runtime/web-server/middleware)。
|
13
|
-
|
14
|
-
:::
|
@@ -4,46 +4,36 @@ sidebar_position: 1
|
|
4
4
|
---
|
5
5
|
# App.[tj]sx
|
6
6
|
|
7
|
-
|
7
|
+
应用使用[自控路由](/guides/basic-features/routes.html#self-controlled-routing)时的入口标识符。
|
8
8
|
|
9
9
|
`App.[tj]sx` 并不是实际的应用入口,Modern.js 会自动生成真正的构建打包的入口文件, 内容大致如下:
|
10
10
|
|
11
11
|
```js
|
12
12
|
import React from 'react';
|
13
|
+
import ReactDOM from 'react-dom/client';
|
13
14
|
import { createApp, bootstrap } from '@modern-js/runtime';
|
14
15
|
// App.[jt]sx
|
15
16
|
import App from '@_modern_js_src/App';
|
16
|
-
|
17
|
-
import {
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
} from '@modern-js/runtime/model';
|
23
|
-
|
24
|
-
const createStatePlugins = config => {
|
25
|
-
const plugins = [];
|
26
|
-
plugins.push(immer(config['immer']));
|
27
|
-
plugins.push(effects(config['effects']));
|
28
|
-
plugins.push(autoActions(config['autoActions']));
|
29
|
-
plugins.push(devtools(config['devtools']));
|
30
|
-
return plugins;
|
31
|
-
};
|
17
|
+
// runtime plugin
|
18
|
+
import { router } from '@modern-js/runtime/plugins';
|
19
|
+
|
20
|
+
const IS_BROWSER = typeof window !== 'undefined' && window.name !== 'nodejs';
|
21
|
+
const MOUNT_ID = 'root';
|
22
|
+
|
32
23
|
let AppWrapper = null;
|
24
|
+
|
33
25
|
function render() {
|
34
26
|
AppWrapper = createApp({
|
35
27
|
plugins: [
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
}),
|
40
|
-
],
|
41
|
-
})(App);
|
28
|
+
router({...{"serverBase":["/"]}, ...App.config?.router}),
|
29
|
+
]
|
30
|
+
})(App)
|
42
31
|
if (IS_BROWSER) {
|
43
|
-
bootstrap(AppWrapper, MOUNT_ID);
|
32
|
+
bootstrap(AppWrapper, MOUNT_ID, null, ReactDOM);
|
44
33
|
}
|
45
|
-
return AppWrapper
|
34
|
+
return AppWrapper
|
46
35
|
}
|
36
|
+
|
47
37
|
AppWrapper = render();
|
48
38
|
export default AppWrapper;
|
49
39
|
```
|