@modern-js/app-tools 3.7.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/modern-bundle-docs.js +7 -0
- package/dist/cjs/builder/generator/createBuilderProviderConfig.js +5 -1
- package/dist/cjs/bundleDocs.js +114 -0
- package/dist/cjs/commands/build.js +2 -1
- package/dist/cjs/commands/deploy.js +4 -2
- package/dist/cjs/commands/index.js +0 -4
- package/dist/cjs/config/default.js +2 -0
- package/dist/cjs/index.js +52 -14
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm/bundleDocs.mjs +62 -0
- package/dist/esm/commands/build.mjs +2 -1
- package/dist/esm/commands/deploy.mjs +4 -2
- package/dist/esm/commands/index.mjs +0 -4
- package/dist/esm/config/default.mjs +2 -0
- package/dist/esm/index.mjs +15 -1
- package/dist/esm/plugins/analyze/index.mjs +2 -2
- package/dist/esm/plugins/analyze/utils.mjs +3 -2
- package/dist/esm/plugins/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm-node/bundleDocs.mjs +63 -0
- package/dist/esm-node/commands/build.mjs +2 -1
- package/dist/esm-node/commands/deploy.mjs +4 -2
- package/dist/esm-node/commands/index.mjs +0 -4
- package/dist/esm-node/config/default.mjs +2 -0
- package/dist/esm-node/index.mjs +15 -1
- package/dist/esm-node/plugins/analyze/index.mjs +2 -2
- package/dist/esm-node/plugins/analyze/utils.mjs +3 -2
- package/dist/esm-node/plugins/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- package/dist/types/bundleDocs.d.ts +20 -0
- package/dist/types/commands/deploy.d.ts +2 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/types/plugins/analyze/utils.d.ts +1 -1
- package/dist/types/types/config/dev.d.ts +6 -0
- package/docs/apis/app/commands.md +241 -0
- package/docs/apis/app/hooks/api/lambda.md +9 -0
- package/docs/apis/app/hooks/config/favicon.md +24 -0
- package/docs/apis/app/hooks/config/html.md +5 -0
- package/docs/apis/app/hooks/config/icon.md +24 -0
- package/docs/apis/app/hooks/config/mock.md +6 -0
- package/docs/apis/app/hooks/config/public.md +26 -0
- package/docs/apis/app/hooks/config/upload.md +50 -0
- package/docs/apis/app/hooks/modern-config.md +5 -0
- package/docs/apis/app/hooks/server/server.md +5 -0
- package/docs/apis/app/hooks/shared.md +3 -0
- package/docs/apis/app/hooks/src/app.md +30 -0
- package/docs/apis/app/hooks/src/entry.md +34 -0
- package/docs/apis/app/hooks/src/entry.server.md +51 -0
- package/docs/apis/app/hooks/src/modern.runtime.md +5 -0
- package/docs/apis/app/hooks/src/routes.md +86 -0
- package/docs/apis/app/hooks/src/server.md +3 -0
- package/docs/apis/app/runtime/bff/use-hono-context.md +27 -0
- package/docs/apis/app/runtime/core/create-root.md +19 -0
- package/docs/apis/app/runtime/core/render.md +39 -0
- package/docs/apis/app/runtime/core/runtime-context.md +156 -0
- package/docs/apis/app/runtime/router/router.md +280 -0
- package/docs/apis/app/runtime/ssr/no-ssr.md +35 -0
- package/docs/apis/app/runtime/ssr/renderStreaming.md +67 -0
- package/docs/apis/app/runtime/ssr/renderString.md +60 -0
- package/docs/apis/app/runtime/ssr/requestHandler.md +44 -0
- package/docs/apis/app/runtime/utility/css-in-js.md +40 -0
- package/docs/apis/app/runtime/utility/head.md +35 -0
- package/docs/apis/app/runtime/utility/loadable.md +82 -0
- package/docs/community/blog/2022-0708-updates.md +91 -0
- package/docs/community/blog/2022-0910-updates.md +76 -0
- package/docs/community/blog/overview.md +63 -0
- package/docs/community/blog/v2-release-note.md +238 -0
- package/docs/community/blog/v3-release-note.md +622 -0
- package/docs/community/contributing-guide.md +253 -0
- package/docs/community/releases.md +27 -0
- package/docs/community/showcase.md +34 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/cross-project.md +20 -0
- package/docs/configure/app/bff/prefix.md +29 -0
- package/docs/configure/app/builder-plugins.md +66 -0
- package/docs/configure/app/dev/asset-prefix.md +13 -0
- package/docs/configure/app/dev/before-start-url.md +17 -0
- package/docs/configure/app/dev/client.md +41 -0
- package/docs/configure/app/dev/hmr.md +10 -0
- package/docs/configure/app/dev/host.md +18 -0
- package/docs/configure/app/dev/https.md +77 -0
- package/docs/configure/app/dev/lazy-compilation.md +39 -0
- package/docs/configure/app/dev/live-reload.md +10 -0
- package/docs/configure/app/dev/mock-dir.md +31 -0
- package/docs/configure/app/dev/progress-bar.md +19 -0
- package/docs/configure/app/dev/server.md +124 -0
- package/docs/configure/app/dev/setup-middlewares.md +32 -0
- package/docs/configure/app/dev/start-url.md +48 -0
- package/docs/configure/app/dev/watch-files.md +27 -0
- package/docs/configure/app/dev/write-to-disk.md +10 -0
- package/docs/configure/app/experiments/source-build.md +31 -0
- package/docs/configure/app/html/app-icon.md +28 -0
- package/docs/configure/app/html/crossorigin.md +10 -0
- package/docs/configure/app/html/favicon.md +16 -0
- package/docs/configure/app/html/inject.md +10 -0
- package/docs/configure/app/html/meta.md +24 -0
- package/docs/configure/app/html/mount-id.md +10 -0
- package/docs/configure/app/html/output-structure.md +10 -0
- package/docs/configure/app/html/script-loading.md +10 -0
- package/docs/configure/app/html/tags.md +15 -0
- package/docs/configure/app/html/template-parameters.md +33 -0
- package/docs/configure/app/html/template.md +10 -0
- package/docs/configure/app/html/title.md +18 -0
- package/docs/configure/app/output/asset-prefix.md +11 -0
- package/docs/configure/app/output/assets-retry.md +77 -0
- package/docs/configure/app/output/charset.md +10 -0
- package/docs/configure/app/output/clean-dist-path.md +16 -0
- package/docs/configure/app/output/convert-to-rem.md +79 -0
- package/docs/configure/app/output/copy.md +10 -0
- package/docs/configure/app/output/css-modules.md +48 -0
- package/docs/configure/app/output/data-uri-limit.md +26 -0
- package/docs/configure/app/output/disable-css-module-extension.md +55 -0
- package/docs/configure/app/output/disable-inline-runtime-chunk.md +41 -0
- package/docs/configure/app/output/disable-svgr.md +16 -0
- package/docs/configure/app/output/disable-ts-checker.md +49 -0
- package/docs/configure/app/output/dist-path.md +43 -0
- package/docs/configure/app/output/enable-asset-manifest.md +36 -0
- package/docs/configure/app/output/enable-css-module-tsdeclaration.md +28 -0
- package/docs/configure/app/output/enable-inline-route-manifests.md +16 -0
- package/docs/configure/app/output/externals.md +20 -0
- package/docs/configure/app/output/filename-hash.md +10 -0
- package/docs/configure/app/output/filename.md +55 -0
- package/docs/configure/app/output/inject-styles.md +10 -0
- package/docs/configure/app/output/inline-scripts.md +29 -0
- package/docs/configure/app/output/inline-styles.md +29 -0
- package/docs/configure/app/output/legal-comments.md +18 -0
- package/docs/configure/app/output/minify.md +22 -0
- package/docs/configure/app/output/override-browserslist.md +22 -0
- package/docs/configure/app/output/polyfill.md +12 -0
- package/docs/configure/app/output/source-map.md +30 -0
- package/docs/configure/app/output/split-route-chunks.md +16 -0
- package/docs/configure/app/output/ssg.md +81 -0
- package/docs/configure/app/output/ssgByEntries.md +90 -0
- package/docs/configure/app/output/svg-default-export.md +30 -0
- package/docs/configure/app/output/temp-dir.md +20 -0
- package/docs/configure/app/performance/build-cache.md +39 -0
- package/docs/configure/app/performance/chunk-split.md +40 -0
- package/docs/configure/app/performance/dns-prefetch.md +15 -0
- package/docs/configure/app/performance/preconnect.md +16 -0
- package/docs/configure/app/performance/prefetch.md +21 -0
- package/docs/configure/app/performance/preload.md +23 -0
- package/docs/configure/app/performance/print-file-size.md +40 -0
- package/docs/configure/app/performance/profile.md +10 -0
- package/docs/configure/app/performance/remove-console.md +10 -0
- package/docs/configure/app/performance/remove-moment-locale.md +10 -0
- package/docs/configure/app/plugins.md +59 -0
- package/docs/configure/app/resolve/alias-strategy.md +10 -0
- package/docs/configure/app/resolve/alias.md +9 -0
- package/docs/configure/app/resolve/condition-names.md +13 -0
- package/docs/configure/app/resolve/dedupe.md +9 -0
- package/docs/configure/app/resolve/extensions.md +13 -0
- package/docs/configure/app/runtime/0-intro.md +58 -0
- package/docs/configure/app/runtime/plugins.md +58 -0
- package/docs/configure/app/runtime/router.md +35 -0
- package/docs/configure/app/security/check-syntax.md +69 -0
- package/docs/configure/app/security/nonce.md +15 -0
- package/docs/configure/app/security/sri.md +20 -0
- package/docs/configure/app/server/base-url.md +26 -0
- package/docs/configure/app/server/port.md +18 -0
- package/docs/configure/app/server/public-routes.md +22 -0
- package/docs/configure/app/server/routes.md +86 -0
- package/docs/configure/app/server/rsc.md +26 -0
- package/docs/configure/app/server/ssr-by-entries.md +25 -0
- package/docs/configure/app/server/ssr.md +78 -0
- package/docs/configure/app/server/tsconfig-path.md +59 -0
- package/docs/configure/app/source/alias-strategy.md +14 -0
- package/docs/configure/app/source/alias.md +23 -0
- package/docs/configure/app/source/config-dir.md +20 -0
- package/docs/configure/app/source/decorators.md +25 -0
- package/docs/configure/app/source/define.md +16 -0
- package/docs/configure/app/source/disable-default-entries.md +28 -0
- package/docs/configure/app/source/enable-async-entry.md +54 -0
- package/docs/configure/app/source/enable-async-pre-entry.md +26 -0
- package/docs/configure/app/source/entries-dir.md +35 -0
- package/docs/configure/app/source/entries.md +179 -0
- package/docs/configure/app/source/exclude.md +10 -0
- package/docs/configure/app/source/global-vars.md +106 -0
- package/docs/configure/app/source/include.md +36 -0
- package/docs/configure/app/source/main-entry-name.md +24 -0
- package/docs/configure/app/source/pre-entry.md +10 -0
- package/docs/configure/app/source/react-compiler.md +68 -0
- package/docs/configure/app/source/transform-import.md +27 -0
- package/docs/configure/app/split-chunks.md +17 -0
- package/docs/configure/app/tools/autoprefixer.md +44 -0
- package/docs/configure/app/tools/bundler-chain.md +26 -0
- package/docs/configure/app/tools/css-extract.md +33 -0
- package/docs/configure/app/tools/css-loader.md +17 -0
- package/docs/configure/app/tools/dev-server.md +113 -0
- package/docs/configure/app/tools/html-plugin.md +41 -0
- package/docs/configure/app/tools/less.md +81 -0
- package/docs/configure/app/tools/lightningcss-loader.md +35 -0
- package/docs/configure/app/tools/minify-css.md +53 -0
- package/docs/configure/app/tools/postcss.md +34 -0
- package/docs/configure/app/tools/rspack.md +10 -0
- package/docs/configure/app/tools/sass.md +78 -0
- package/docs/configure/app/tools/style-loader.md +10 -0
- package/docs/configure/app/tools/swc.md +65 -0
- package/docs/configure/app/tools/ts-checker.md +109 -0
- package/docs/configure/app/usage.md +276 -0
- package/docs/guides/advanced-features/bff/cross-project.md +109 -0
- package/docs/guides/advanced-features/bff/extend-server.md +120 -0
- package/docs/guides/advanced-features/bff/frameworks.md +124 -0
- package/docs/guides/advanced-features/bff/function.md +314 -0
- package/docs/guides/advanced-features/bff/operators.md +554 -0
- package/docs/guides/advanced-features/bff/sdk.md +116 -0
- package/docs/guides/advanced-features/bff/upload.md +101 -0
- package/docs/guides/advanced-features/bff.md +18 -0
- package/docs/guides/advanced-features/build-performance.md +130 -0
- package/docs/guides/advanced-features/compatibility.md +120 -0
- package/docs/guides/advanced-features/international/advanced.md +128 -0
- package/docs/guides/advanced-features/international/api.md +231 -0
- package/docs/guides/advanced-features/international/best-practices.md +286 -0
- package/docs/guides/advanced-features/international/configuration.md +227 -0
- package/docs/guides/advanced-features/international/locale-detection.md +126 -0
- package/docs/guides/advanced-features/international/quick-start.md +128 -0
- package/docs/guides/advanced-features/international/resource-loading.md +154 -0
- package/docs/guides/advanced-features/international/routing.md +130 -0
- package/docs/guides/advanced-features/international.md +27 -0
- package/docs/guides/advanced-features/low-level.md +46 -0
- package/docs/guides/advanced-features/page-performance/code-split.md +77 -0
- package/docs/guides/advanced-features/page-performance/inline-assets.md +159 -0
- package/docs/guides/advanced-features/page-performance/optimize-bundle.md +97 -0
- package/docs/guides/advanced-features/page-performance/react-compiler.md +69 -0
- package/docs/guides/advanced-features/server-monitor/logger.md +41 -0
- package/docs/guides/advanced-features/server-monitor/metrics.md +58 -0
- package/docs/guides/advanced-features/server-monitor/monitors.md +242 -0
- package/docs/guides/advanced-features/source-build.md +164 -0
- package/docs/guides/advanced-features/web-server.md +288 -0
- package/docs/guides/basic-features/alias.md +102 -0
- package/docs/guides/basic-features/css/css-in-js.md +72 -0
- package/docs/guides/basic-features/css/css-modules.md +212 -0
- package/docs/guides/basic-features/css/css.md +27 -0
- package/docs/guides/basic-features/css/tailwindcss.md +27 -0
- package/docs/guides/basic-features/data/data-cache.md +510 -0
- package/docs/guides/basic-features/data/data-fetch.md +415 -0
- package/docs/guides/basic-features/data/data-write.md +227 -0
- package/docs/guides/basic-features/debug/mock.md +109 -0
- package/docs/guides/basic-features/debug/proxy.md +21 -0
- package/docs/guides/basic-features/debug/rsdoctor.md +62 -0
- package/docs/guides/basic-features/debug/using-storybook.md +112 -0
- package/docs/guides/basic-features/deploy.md +458 -0
- package/docs/guides/basic-features/env-vars.md +177 -0
- package/docs/guides/basic-features/html.md +255 -0
- package/docs/guides/basic-features/output-files.md +141 -0
- package/docs/guides/basic-features/render/before-render.md +108 -0
- package/docs/guides/basic-features/render/overview.md +47 -0
- package/docs/guides/basic-features/render/rsc.md +525 -0
- package/docs/guides/basic-features/render/ssg.md +228 -0
- package/docs/guides/basic-features/render/ssr-cache.md +201 -0
- package/docs/guides/basic-features/render/ssr.md +321 -0
- package/docs/guides/basic-features/render/streaming-ssr.md +264 -0
- package/docs/guides/basic-features/routes/config-routes.md +426 -0
- package/docs/guides/basic-features/routes/routes.md +498 -0
- package/docs/guides/basic-features/static-assets/json-files.md +120 -0
- package/docs/guides/basic-features/static-assets/svg-assets.md +168 -0
- package/docs/guides/basic-features/static-assets/wasm-assets.md +62 -0
- package/docs/guides/basic-features/static-assets.md +160 -0
- package/docs/guides/basic-features/testing/playwright.md +120 -0
- package/docs/guides/basic-features/testing/rstest.md +251 -0
- package/docs/guides/concept/builder.md +37 -0
- package/docs/guides/concept/entries.md +319 -0
- package/docs/guides/concept/server.md +35 -0
- package/docs/guides/get-started/ai-coding-agents.md +58 -0
- package/docs/guides/get-started/glossary.md +63 -0
- package/docs/guides/get-started/introduction.md +36 -0
- package/docs/guides/get-started/quick-start.md +236 -0
- package/docs/guides/get-started/tech-stack.md +82 -0
- package/docs/guides/get-started/upgrade.md +123 -0
- package/docs/guides/topic-detail/module-federation/application.md +116 -0
- package/docs/guides/topic-detail/module-federation/deploy.md +104 -0
- package/docs/guides/topic-detail/module-federation/i18n.md +670 -0
- package/docs/guides/topic-detail/module-federation/introduce.md +35 -0
- package/docs/guides/topic-detail/module-federation/ssr.md +118 -0
- package/docs/guides/topic-detail/module-federation/usage.md +219 -0
- package/docs/guides/troubleshooting/builder.md +110 -0
- package/docs/guides/troubleshooting/cli.md +35 -0
- package/docs/guides/troubleshooting/dependencies.md +119 -0
- package/docs/guides/troubleshooting/hmr.md +144 -0
- package/docs/guides/upgrade/config.md +963 -0
- package/docs/guides/upgrade/entry.md +463 -0
- package/docs/guides/upgrade/other.md +183 -0
- package/docs/guides/upgrade/overview.md +33 -0
- package/docs/guides/upgrade/tailwindcss.md +91 -0
- package/docs/guides/upgrade/web-server.md +109 -0
- package/docs/index.md +33 -0
- package/docs/llms.txt +285 -0
- package/docs/plugin/cli-plugins/api.md +573 -0
- package/docs/plugin/cli-plugins/life-cycle.md +2 -0
- package/docs/plugin/introduction.md +152 -0
- package/docs/plugin/official/cli-plugins/plugin-bff.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-ssg.md +5 -0
- package/docs/plugin/official/cli-plugins/plugin-styled-components.md +5 -0
- package/docs/plugin/official/cli-plugins.md +4 -0
- package/docs/plugin/plugin-system.md +238 -0
- package/docs/plugin/runtime-plugins/api.md +194 -0
- package/docs/plugin/runtime-plugins/life-cycle.md +2 -0
- package/docs/plugin/server-plugins/api.md +209 -0
- package/docs/plugin/server-plugins/life-cycle.md +13 -0
- package/docs/tutorials/examples/csr-auth.md +9 -0
- package/docs/tutorials/foundations/introduction.md +16 -0
- package/package.json +46 -13
|
@@ -17,7 +17,7 @@ const serverBuild = ()=>({
|
|
|
17
17
|
name: '@modern-js/server-build',
|
|
18
18
|
setup (api) {
|
|
19
19
|
api.onAfterBuild(async ()=>{
|
|
20
|
-
const { appDirectory, distDirectory, metaName } = api.getAppContext();
|
|
20
|
+
const { appDirectory, distDirectory, metaName, moduleType } = api.getAppContext();
|
|
21
21
|
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) return;
|
|
22
22
|
const modernConfig = api.getNormalizedConfig();
|
|
23
23
|
const distDir = path.resolve(distDirectory);
|
|
@@ -37,7 +37,8 @@ const serverBuild = ()=>({
|
|
|
37
37
|
}, {
|
|
38
38
|
sourceDirs,
|
|
39
39
|
distDir,
|
|
40
|
-
tsconfigPath
|
|
40
|
+
tsconfigPath,
|
|
41
|
+
moduleType
|
|
41
42
|
});
|
|
42
43
|
});
|
|
43
44
|
}
|
|
@@ -15,6 +15,10 @@ function modifyOutputConfig(config, appContext) {
|
|
|
15
15
|
};
|
|
16
16
|
}
|
|
17
17
|
function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
18
|
+
const builderDevConfig = {
|
|
19
|
+
...resolveConfig.dev
|
|
20
|
+
};
|
|
21
|
+
delete builderDevConfig.mockDir;
|
|
18
22
|
const htmlConfig = {
|
|
19
23
|
...resolveConfig.html
|
|
20
24
|
};
|
|
@@ -33,7 +37,7 @@ function createBuilderProviderConfig(resolveConfig, appContext) {
|
|
|
33
37
|
...resolveConfig.source
|
|
34
38
|
},
|
|
35
39
|
dev: {
|
|
36
|
-
...
|
|
40
|
+
...builderDevConfig,
|
|
37
41
|
port: appContext.port
|
|
38
42
|
},
|
|
39
43
|
server: serverConfig,
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import "node:module";
|
|
2
|
+
import node_fs from "node:fs";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
const DEFAULT_INDEX_FILE = 'llms.txt';
|
|
5
|
+
const DEFAULT_EXCLUDED_DIRS = [
|
|
6
|
+
'zh'
|
|
7
|
+
];
|
|
8
|
+
function bundleDocs({ source, target, indexFile = DEFAULT_INDEX_FILE, excludedDirs = DEFAULT_EXCLUDED_DIRS }) {
|
|
9
|
+
if (!node_fs.existsSync(source)) {
|
|
10
|
+
console.warn(`[bundle-docs] docs build output not found: ${source}`);
|
|
11
|
+
console.warn('[bundle-docs] skipping the bundled docs — build the docs site first if you need them');
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
node_fs.rmSync(target, {
|
|
15
|
+
recursive: true,
|
|
16
|
+
force: true
|
|
17
|
+
});
|
|
18
|
+
const isBundled = (rel)=>rel === indexFile || rel.endsWith('.md') && !excludedDirs.some((dir)=>rel.startsWith(`${dir}${node_path.sep}`));
|
|
19
|
+
let count = 0;
|
|
20
|
+
for (const entry of node_fs.readdirSync(source, {
|
|
21
|
+
recursive: true,
|
|
22
|
+
withFileTypes: true
|
|
23
|
+
})){
|
|
24
|
+
if (!entry.isFile()) continue;
|
|
25
|
+
const from = node_path.join(entry.parentPath ?? entry.path, entry.name);
|
|
26
|
+
const rel = node_path.relative(source, from);
|
|
27
|
+
if (!isBundled(rel)) continue;
|
|
28
|
+
const to = node_path.join(target, rel);
|
|
29
|
+
node_fs.mkdirSync(node_path.dirname(to), {
|
|
30
|
+
recursive: true
|
|
31
|
+
});
|
|
32
|
+
node_fs.copyFileSync(from, to);
|
|
33
|
+
count++;
|
|
34
|
+
}
|
|
35
|
+
if (0 === count) throw new Error(`[bundle-docs] no files copied from ${source}`);
|
|
36
|
+
return count;
|
|
37
|
+
}
|
|
38
|
+
function parseArgs(argv) {
|
|
39
|
+
const options = {};
|
|
40
|
+
for(let i = 0; i < argv.length; i += 2){
|
|
41
|
+
const key = argv[i]?.replace(/^--/, '');
|
|
42
|
+
const value = argv[i + 1];
|
|
43
|
+
if (key && value) options[key] = value;
|
|
44
|
+
}
|
|
45
|
+
return options;
|
|
46
|
+
}
|
|
47
|
+
function runBundleDocsCli(pkgRoot) {
|
|
48
|
+
const args = parseArgs(process.argv.slice(2));
|
|
49
|
+
const source = args.source ? node_path.resolve(process.cwd(), args.source) : node_path.resolve(pkgRoot, '../../document/doc_build');
|
|
50
|
+
const target = args.target ? node_path.resolve(process.cwd(), args.target) : node_path.resolve(pkgRoot, 'docs');
|
|
51
|
+
try {
|
|
52
|
+
const count = bundleDocs({
|
|
53
|
+
source,
|
|
54
|
+
target,
|
|
55
|
+
indexFile: args.index
|
|
56
|
+
});
|
|
57
|
+
if (count > 0) console.log(`[bundle-docs] bundled ${count} doc files into docs`);
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.error(error.message);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
export { bundleDocs, runBundleDocsCli };
|
|
@@ -57,8 +57,9 @@ const build = async (api, options)=>{
|
|
|
57
57
|
logger.info('Starting production build...');
|
|
58
58
|
if (!appContext.builder) throw new Error('Expect the Builder to have been initialized, But the appContext.builder received `undefined`');
|
|
59
59
|
await appContext.builder.onAfterBuild(async ()=>copyEnvFiles(appContext.appDirectory, appContext.distDirectory));
|
|
60
|
-
await appContext.builder.build({
|
|
60
|
+
const buildResult = await appContext.builder.build({
|
|
61
61
|
watch: options?.watch
|
|
62
62
|
});
|
|
63
|
+
if (!options?.watch) await buildResult?.close();
|
|
63
64
|
};
|
|
64
65
|
export { build };
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { getServerPlugins } from "../utils/loadPlugins.mjs";
|
|
3
|
-
|
|
3
|
+
import { build } from "./build.mjs";
|
|
4
|
+
const deploy = async (api, options = {})=>{
|
|
4
5
|
const hooks = api.getHooks();
|
|
5
6
|
const { metaName } = api.getAppContext();
|
|
6
|
-
await getServerPlugins(api, metaName);
|
|
7
|
+
if (options.skipBuild) await getServerPlugins(api, metaName);
|
|
8
|
+
else await build(api);
|
|
7
9
|
await hooks.onBeforeDeploy.call(options);
|
|
8
10
|
await hooks.deploy.call();
|
|
9
11
|
await hooks.onAfterDeploy.call(options);
|
|
@@ -20,10 +20,6 @@ const serverCommand = (program, api)=>{
|
|
|
20
20
|
};
|
|
21
21
|
const deployCommand = (program, api)=>{
|
|
22
22
|
program.command('deploy').usage('[options]').option('-c --config <config>', i18n.t(localeKeys.command.shared.config)).option('-s --skip-build', i18n.t(localeKeys.command.shared.skipBuild)).description(i18n.t(localeKeys.command.deploy.describe)).action(async (options)=>{
|
|
23
|
-
if (!options.skipBuild) {
|
|
24
|
-
const { build } = await import("./build.mjs");
|
|
25
|
-
await build(api);
|
|
26
|
-
}
|
|
27
23
|
const { deploy } = await import("./deploy.mjs");
|
|
28
24
|
await deploy(api, options);
|
|
29
25
|
process.exit(0);
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
+
import { AGGRED_DIR } from "@modern-js/server-core";
|
|
2
3
|
import { DEFAULT_ENTRY_NAME } from "@modern-js/utils";
|
|
3
4
|
import { getAutoInjectEnv } from "../utils/env.mjs";
|
|
4
5
|
function createDefaultConfig(appContext) {
|
|
5
6
|
const dev = {
|
|
7
|
+
mockDir: `./${AGGRED_DIR.mock}`,
|
|
6
8
|
cliShortcuts: {
|
|
7
9
|
help: false,
|
|
8
10
|
custom: (shortcuts = [])=>shortcuts.filter(({ key })=>'r' !== key && 'u' !== key && 'o' !== key)
|
package/dist/esm-node/index.mjs
CHANGED
|
@@ -79,7 +79,18 @@ const appTools = ()=>({
|
|
|
79
79
|
].some((tag)=>getArgv().includes(tag));
|
|
80
80
|
if (isSkipBuild) return;
|
|
81
81
|
}
|
|
82
|
-
|
|
82
|
+
const { command: contextCommand } = api.getAppContext();
|
|
83
|
+
const shouldClean = [
|
|
84
|
+
'dev',
|
|
85
|
+
'start',
|
|
86
|
+
'build',
|
|
87
|
+
'deploy'
|
|
88
|
+
].includes(command) || [
|
|
89
|
+
'dev',
|
|
90
|
+
'start',
|
|
91
|
+
'build'
|
|
92
|
+
].includes(contextCommand);
|
|
93
|
+
if (shouldClean) {
|
|
83
94
|
const resolvedConfig = api.getNormalizedConfig();
|
|
84
95
|
if (resolvedConfig.output.cleanDistPath) {
|
|
85
96
|
const appContext = api.getAppContext();
|
|
@@ -119,8 +130,11 @@ const appTools = ()=>({
|
|
|
119
130
|
});
|
|
120
131
|
const src = appTools;
|
|
121
132
|
export { defineConfig } from "./defineConfig.mjs";
|
|
133
|
+
export { build } from "./commands/build.mjs";
|
|
134
|
+
export { deploy } from "./commands/deploy.mjs";
|
|
122
135
|
export { dev } from "./commands/dev.mjs";
|
|
123
136
|
export { serve } from "./commands/serve.mjs";
|
|
137
|
+
export { closeServer } from "./utils/createServer.mjs";
|
|
124
138
|
export { resolveModernRsbuildConfig } from "./rsbuild.mjs";
|
|
125
139
|
export { mergeConfig } from "@modern-js/plugin/cli";
|
|
126
140
|
export default src;
|
|
@@ -24,7 +24,7 @@ const analyze = ()=>({
|
|
|
24
24
|
const resolvedConfig = api.getNormalizedConfig();
|
|
25
25
|
const hooks = api.getHooks();
|
|
26
26
|
try {
|
|
27
|
-
if (checkIsBuildCommands()) fs.emptydirSync(appContext.internalDirectory);
|
|
27
|
+
if (checkIsBuildCommands(appContext.command)) fs.emptydirSync(appContext.internalDirectory);
|
|
28
28
|
} catch {}
|
|
29
29
|
const apiOnly = await isApiOnly(appContext.appDirectory, resolvedConfig.source?.entriesDir, appContext.apiDirectory);
|
|
30
30
|
const [{ getProdServerRoutes }] = await Promise.all([
|
|
@@ -118,7 +118,7 @@ const analyze = ()=>({
|
|
|
118
118
|
htmlTemplates
|
|
119
119
|
};
|
|
120
120
|
api.updateAppContext(appContext);
|
|
121
|
-
if (checkIsBuildCommands()) {
|
|
121
|
+
if (checkIsBuildCommands(appContext.command)) {
|
|
122
122
|
await hooks.generateEntryCode.call({
|
|
123
123
|
entrypoints
|
|
124
124
|
});
|
|
@@ -53,7 +53,7 @@ const parseModule = async ({ source, filename })=>{
|
|
|
53
53
|
return await parse(content);
|
|
54
54
|
};
|
|
55
55
|
const getServerCombinedModuleFile = (internalDirectory, entryName)=>path.join(internalDirectory, entryName, 'server-loader-combined.js');
|
|
56
|
-
const checkIsBuildCommands = ()=>{
|
|
56
|
+
const checkIsBuildCommands = (contextCommand)=>{
|
|
57
57
|
const buildCommands = [
|
|
58
58
|
'dev',
|
|
59
59
|
'start',
|
|
@@ -63,7 +63,8 @@ const checkIsBuildCommands = ()=>{
|
|
|
63
63
|
'dev-worker'
|
|
64
64
|
];
|
|
65
65
|
const command = getCommand();
|
|
66
|
-
|
|
66
|
+
if (buildCommands.includes(command)) return true;
|
|
67
|
+
return 'dev' === contextCommand || 'start' === contextCommand || 'build' === contextCommand || 'deploy' === contextCommand;
|
|
67
68
|
};
|
|
68
69
|
const checkIsServeCommand = ()=>{
|
|
69
70
|
const command = getCommand();
|
|
@@ -26,7 +26,7 @@ const initialize = ()=>({
|
|
|
26
26
|
api.modifyResolvedConfig(async (resolved)=>{
|
|
27
27
|
let appContext = api.getAppContext();
|
|
28
28
|
const userConfig = api.getConfig();
|
|
29
|
-
const port = await getServerPort(resolved);
|
|
29
|
+
const port = await getServerPort(resolved, appContext.command);
|
|
30
30
|
appContext = {
|
|
31
31
|
...appContext,
|
|
32
32
|
port,
|
|
@@ -61,9 +61,10 @@ function stabilizeConfig(resolve, config, keys) {
|
|
|
61
61
|
resolve[key] = config[key] || {};
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
|
-
async function getServerPort(config) {
|
|
64
|
+
async function getServerPort(config, contextCommand) {
|
|
65
65
|
const prodPort = Number(process.env.PORT) || config.server.port || 8080;
|
|
66
|
-
|
|
66
|
+
const isProgrammaticDev = 'dev' === contextCommand || 'start' === contextCommand;
|
|
67
|
+
if (isDev() && (isDevCommand() || isProgrammaticDev)) return getPort(Number(process.env.PORT) || prodPort);
|
|
67
68
|
return prodPort;
|
|
68
69
|
}
|
|
69
70
|
export default initialize;
|
|
@@ -18,7 +18,7 @@ const serverBuild = ()=>({
|
|
|
18
18
|
name: '@modern-js/server-build',
|
|
19
19
|
setup (api) {
|
|
20
20
|
api.onAfterBuild(async ()=>{
|
|
21
|
-
const { appDirectory, distDirectory, metaName } = api.getAppContext();
|
|
21
|
+
const { appDirectory, distDirectory, metaName, moduleType } = api.getAppContext();
|
|
22
22
|
if (!checkHasCache(appDirectory) && !checkHasConfig(appDirectory, metaName)) return;
|
|
23
23
|
const modernConfig = api.getNormalizedConfig();
|
|
24
24
|
const distDir = path.resolve(distDirectory);
|
|
@@ -38,7 +38,8 @@ const serverBuild = ()=>({
|
|
|
38
38
|
}, {
|
|
39
39
|
sourceDirs,
|
|
40
40
|
distDir,
|
|
41
|
-
tsconfigPath
|
|
41
|
+
tsconfigPath,
|
|
42
|
+
moduleType
|
|
42
43
|
});
|
|
43
44
|
});
|
|
44
45
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface BundleDocsOptions {
|
|
2
|
+
/** Docs site build output (e.g. `doc_build`). */
|
|
3
|
+
source: string;
|
|
4
|
+
/** Directory to write the bundle to. */
|
|
5
|
+
target: string;
|
|
6
|
+
/** Index file to ship alongside the pages. */
|
|
7
|
+
indexFile?: string;
|
|
8
|
+
/** Top-level directories to skip. */
|
|
9
|
+
excludedDirs?: string[];
|
|
10
|
+
}
|
|
11
|
+
/** @returns files copied, or 0 when the source is absent */
|
|
12
|
+
export declare function bundleDocs({ source, target, indexFile, excludedDirs, }: BundleDocsOptions): number;
|
|
13
|
+
/**
|
|
14
|
+
* `modern-bundle-docs --source <doc_build> --target <pkg>/docs`; both default
|
|
15
|
+
* to this repo's layout.
|
|
16
|
+
*
|
|
17
|
+
* @param pkgRoot supplied by the bin shim — the compiled module cannot know
|
|
18
|
+
* its own package root portably across output formats.
|
|
19
|
+
*/
|
|
20
|
+
export declare function runBundleDocsCli(pkgRoot: string): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { CLIPluginAPI } from '@modern-js/plugin';
|
|
2
2
|
import type { AppTools } from '../types';
|
|
3
|
-
|
|
3
|
+
import type { DeployOptions } from '../utils/types';
|
|
4
|
+
export declare const deploy: (api: CLIPluginAPI<AppTools>, options?: DeployOptions) => Promise<void>;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ import { initAppContext } from './utils/initAppContext';
|
|
|
3
3
|
export * from './defineConfig';
|
|
4
4
|
export declare const appTools: () => CliPlugin<AppTools>;
|
|
5
5
|
export { defineConfig } from './defineConfig';
|
|
6
|
+
export { build } from './commands/build';
|
|
7
|
+
export { deploy } from './commands/deploy';
|
|
6
8
|
export { dev } from './commands/dev';
|
|
7
9
|
export { serve } from './commands/serve';
|
|
8
|
-
export
|
|
10
|
+
export { closeServer } from './utils/createServer';
|
|
11
|
+
export type { BuildOptions, DeployOptions, DevOptions } from './utils/types';
|
|
9
12
|
export { generateWatchFiles } from './utils/generateWatchFiles';
|
|
10
13
|
export { resolveModernRsbuildConfig, type ResolveModernRsbuildConfigOptions, } from './rsbuild';
|
|
11
14
|
export * from './types';
|
|
@@ -5,6 +5,6 @@ export declare const parseModule: ({ source, filename, }: {
|
|
|
5
5
|
filename: string;
|
|
6
6
|
}) => Promise<readonly [imports: readonly import("es-module-lexer").ImportSpecifier[], exports: readonly import("es-module-lexer").ExportSpecifier[], facade: boolean, hasModuleSyntax: boolean]>;
|
|
7
7
|
export declare const getServerCombinedModuleFile: (internalDirectory: string, entryName: string) => string;
|
|
8
|
-
export declare const checkIsBuildCommands: () => boolean;
|
|
8
|
+
export declare const checkIsBuildCommands: (contextCommand?: string) => boolean;
|
|
9
9
|
export declare const checkIsServeCommand: () => boolean;
|
|
10
10
|
export declare const isSubDirOrEqual: (parent: string, child: string) => boolean;
|
|
@@ -47,6 +47,12 @@ export interface DevServerUserConfig {
|
|
|
47
47
|
* Although its name is the same as in Rsbuild, it is consumed by Modern.js.
|
|
48
48
|
*/
|
|
49
49
|
export type DevUserConfig = Omit<BuilderDevConfig, 'setupMiddlewares'> & {
|
|
50
|
+
/**
|
|
51
|
+
* Customize the directory containing the Mock API entry file.
|
|
52
|
+
* Relative paths are resolved from the application directory.
|
|
53
|
+
* @default './config/mock'
|
|
54
|
+
*/
|
|
55
|
+
mockDir?: string;
|
|
50
56
|
setupMiddlewares?: SetupMiddlewares;
|
|
51
57
|
/**
|
|
52
58
|
* Dev server specific options.
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# Commands
|
|
2
|
+
|
|
3
|
+
Modern.js has some built-in commands that can help you quickly start a development server, build production environment code, and more.
|
|
4
|
+
|
|
5
|
+
Through this chapter, you can learn about the built-in commands of Modern.js and how to use them.
|
|
6
|
+
|
|
7
|
+
## modern dev
|
|
8
|
+
|
|
9
|
+
The `modern dev` command is used to start a local development server and compile the source code in the development environment.
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
Usage: modern dev [options]
|
|
13
|
+
|
|
14
|
+
Options:
|
|
15
|
+
-e --entry <entry> compiler by entry
|
|
16
|
+
-c --config <config> specify the configuration file, which can be a relative or absolute path
|
|
17
|
+
-h, --help show command help
|
|
18
|
+
--web-only only start web service
|
|
19
|
+
--api-only only start API service
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
After running `modern dev`, Modern.js will watch source file changes and apply hot module replacement.
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
$ modern dev
|
|
26
|
+
|
|
27
|
+
info Starting dev server...
|
|
28
|
+
|
|
29
|
+
> Local: http://localhost:8080/
|
|
30
|
+
> Network: http://192.168.0.1:8080/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
### Compile Partial Pages
|
|
34
|
+
|
|
35
|
+
In multi-page (MPA) projects, the `--entry` option can be added to specify one or more pages to compile. In this way, only part of the code in the project will be compiled, and the dev startup speed will be faster.
|
|
36
|
+
|
|
37
|
+
For example, execute `modern dev --entry`, the entry selector will be displayed in the command line interface:
|
|
38
|
+
|
|
39
|
+
```text
|
|
40
|
+
$ modern dev --entry
|
|
41
|
+
|
|
42
|
+
? Please select the entry that needs to be built
|
|
43
|
+
❯ ◯ foo
|
|
44
|
+
◯ bar
|
|
45
|
+
◯ baz
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For example, if you select the `foo` entry, only the code related to the `foo` entry will be compiled, and the code of other pages will not be compiled.
|
|
49
|
+
|
|
50
|
+
### Specify the page by parameter
|
|
51
|
+
|
|
52
|
+
You can also specify the page name through parameters after `--entry`, and the names of multiple pages can be separated by commas.
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
# Compile foo page
|
|
56
|
+
modern dev --entry foo
|
|
57
|
+
|
|
58
|
+
# Compile foo and bar pages
|
|
59
|
+
modern dev --entry foo,bar
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## modern start
|
|
63
|
+
|
|
64
|
+
`modern start` is an alias of `modern dev` command, the usage of the two are exactly the same.
|
|
65
|
+
|
|
66
|
+
## modern build
|
|
67
|
+
|
|
68
|
+
The `modern build` command will build production-ready artifacts in the `dist/` directory by default. You can specify the output directory by modifying the configuration [`output.distPath`](/configure/app/output/dist-path.md).
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
Usage: modern build [options]
|
|
72
|
+
|
|
73
|
+
Options:
|
|
74
|
+
-c --config <config> specify the configuration file, which can be a relative or absolute path
|
|
75
|
+
-h, --help show command help
|
|
76
|
+
-w --watch turn on watch mode, watch for changes and rebuild
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## modern new
|
|
80
|
+
|
|
81
|
+
The `modern new` command is used to enable features in an existing project.
|
|
82
|
+
|
|
83
|
+
For example, add application entry, enable some optional features such as BFF, micro frontend, etc.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
Usage: modern new [options]
|
|
87
|
+
|
|
88
|
+
Options:
|
|
89
|
+
--config-file <configFile> specify the configuration file, which can be a relative or absolute path
|
|
90
|
+
--lang <lang> set the language (zh or en) for the new command.
|
|
91
|
+
-d, --debug using debug mode to log something (default: false)
|
|
92
|
+
-c, --config <config> set default generator config(json string)
|
|
93
|
+
--dist-tag <tag> use specified tag version for its generator
|
|
94
|
+
--registry set npm registry url to run npm command
|
|
95
|
+
-h, --help show command help
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Add Entry
|
|
99
|
+
|
|
100
|
+
In the project, execute the `new` command to add entries as follows:
|
|
101
|
+
|
|
102
|
+
```text
|
|
103
|
+
$ npx modern new
|
|
104
|
+
? Please select the operation you want: Create Element
|
|
105
|
+
? Please select the type of element to create: New "entry"
|
|
106
|
+
? Please fill in the entry name: entry
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Enable Features
|
|
110
|
+
|
|
111
|
+
In the project, execute the `new` command to enable features as follows:
|
|
112
|
+
|
|
113
|
+
```text
|
|
114
|
+
$ npx modern new
|
|
115
|
+
? Please select the operation you want: Enable Features
|
|
116
|
+
? Please select the feature name: (Use arrow keys)
|
|
117
|
+
❯ Enable BFF
|
|
118
|
+
Enable SSG
|
|
119
|
+
Enable Micro Frontend
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
:::tip
|
|
123
|
+
The `--config` parameter needs to use a JSON string.
|
|
124
|
+
|
|
125
|
+
pnpm does not support the use of JSON strings as parameter values currently. Use `npm new` to turn on.【[Relate Issue](https://github.com/pnpm/pnpm/issues/3876)】
|
|
126
|
+
:::
|
|
127
|
+
|
|
128
|
+
## modern serve
|
|
129
|
+
|
|
130
|
+
The `modern serve` command is used to start a Modern.js project in the production environment. It can also be used to preview the artifacts built for the production environment locally. Please note that you need to execute the [`build`](/apis/app/commands.md#modern-build) command beforehand to generate the corresponding artifacts.
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
Usage: modern serve [options]
|
|
134
|
+
|
|
135
|
+
Options:
|
|
136
|
+
-c --config <config> specify the configuration file, which can be a relative or absolute path
|
|
137
|
+
-h, --help show command help
|
|
138
|
+
--api-only only run API service
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
By default, the project will run in `localhost:8080`, you can modify the server port number with `server.port`:
|
|
142
|
+
|
|
143
|
+
```js
|
|
144
|
+
export default defineConfig({
|
|
145
|
+
server: {
|
|
146
|
+
port: 8081,
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## modern upgrade
|
|
152
|
+
|
|
153
|
+
Execute the command `npx modern upgrade` in the project, by default, dependencies in the `package.json` are updated to the latest version.
|
|
154
|
+
|
|
155
|
+
```bash
|
|
156
|
+
Usage: modern upgrade [options]
|
|
157
|
+
|
|
158
|
+
Options:
|
|
159
|
+
--config <config> specify the configuration file, which can be a relative or absolute path
|
|
160
|
+
--registry <registry> specify npm registry (default: "")
|
|
161
|
+
-d,--debug using debug mode to log something (default: false)
|
|
162
|
+
--cwd <cwd> app directory (default: "")
|
|
163
|
+
-h, --help show command help
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
## modern inspect
|
|
167
|
+
|
|
168
|
+
The `modern inspect` command is used to view the Modern.js config, [Rsbuild config](https://v2.rsbuild.rs/config/index) and Rspack config of the project.
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
Usage: modern inspect [options]
|
|
172
|
+
|
|
173
|
+
Options:
|
|
174
|
+
--env <env> view the configuration in the target environment (default: "development")
|
|
175
|
+
--output <output> Specify the path to output in the dist (default: "./")
|
|
176
|
+
--verbose Show the full function in the result
|
|
177
|
+
-c --config <config> specify the configuration file, which can be a relative or absolute path
|
|
178
|
+
-h, --help show command help
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
After executing the command `npx modern inspect` in the project root directory, the following files will be generated in the `dist` directory of the project:
|
|
182
|
+
|
|
183
|
+
- `modern.js.config.mjs`:The Modern.js configuration currently used.
|
|
184
|
+
- `rsbuild.config.mjs`: The Rsbuild config to use at build time.
|
|
185
|
+
- `rspack.config.web.mjs`: The Rspack config used by to use at build time.
|
|
186
|
+
|
|
187
|
+
```bash
|
|
188
|
+
➜ npx modern inspect
|
|
189
|
+
|
|
190
|
+
Inspect config succeed, open following files to view the content:
|
|
191
|
+
|
|
192
|
+
- Rsbuild Config: /root/my-project/dist/rsbuild.config.mjs
|
|
193
|
+
- Rspack Config (web): /root/my-project/dist/rspack.config.web.mjs
|
|
194
|
+
- Modern.js Config: /root/my-project/dist/modern.js.config.mjs
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
### Configuration Env
|
|
198
|
+
|
|
199
|
+
By default, the inspect command will output the development configs, you can use the `--env production` option to output the production configs:
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
modern inspect --env production
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Verbose content
|
|
206
|
+
|
|
207
|
+
By default, the inspect command will omit the function content in the config object, you can use the `--verbose` option to output the full content of the function:
|
|
208
|
+
|
|
209
|
+
```bash
|
|
210
|
+
modern inspect --verbose
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### SSR Configuration
|
|
214
|
+
|
|
215
|
+
If the project has enabled SSR, an additional `rspack.config.node.mjs` file will be generated in the `dist/`, corresponding to the Rspack configuration at SSR build time.
|
|
216
|
+
|
|
217
|
+
```bash
|
|
218
|
+
➜ npx modern inspect
|
|
219
|
+
|
|
220
|
+
Inspect config succeed, open following files to view the content:
|
|
221
|
+
|
|
222
|
+
- Rsbuild Config: /root/my-project/dist/rsbuild.config.mjs
|
|
223
|
+
- Rspack Config (web): /root/my-project/dist/rspack.config.web.mjs
|
|
224
|
+
- Rspack Config (node): /root/my-project/dist/rspack.config.node.mjs
|
|
225
|
+
- Modern.js Config: /root/my-project/dist/modern.js.config.mjs
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
## modern deploy
|
|
229
|
+
|
|
230
|
+
The `modern deploy` command is used to generate artifacts required for the deployment platform.
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
Usage: modern deploy [options]
|
|
234
|
+
|
|
235
|
+
Options:
|
|
236
|
+
-c --config <config> Specify configuration file path, either relative or absolute
|
|
237
|
+
-s --skip-build Skip the build stage
|
|
238
|
+
-h, --help Display command help
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
For more details, refer to [Deploy Application](/guides/basic-features/deploy.md).
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# lambda/\*.ts
|
|
2
|
+
|
|
3
|
+
After enabling BFF, the files under the `lambda/` directory will be registered as BFF routes according to conventions.
|
|
4
|
+
|
|
5
|
+
:::note
|
|
6
|
+
The files can be written in `js` or `ts` languages, but they must use `esm` syntax to export functions.
|
|
7
|
+
:::
|
|
8
|
+
|
|
9
|
+
For detailed information, refer to [BFF API Routes](/guides/advanced-features/bff/function.md#api-routes).
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Favicon
|
|
2
|
+
|
|
3
|
+
When there is a `favicon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.favicon](/configure/app/html/favicon.md) configuration option for generating the favicon icon on the page:
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
./config
|
|
7
|
+
└── favicon.ico
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
After the build is completed, you can see the following tags automatically generated in HTML:
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<link rel="icon" href="/favicon.ico" />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Order
|
|
17
|
+
|
|
18
|
+
When setting up the favicon, Modern.js looks for files in the following order:
|
|
19
|
+
|
|
20
|
+
- `favicon.png`
|
|
21
|
+
- `favicon.jpg`
|
|
22
|
+
- `favicon.jpeg`
|
|
23
|
+
- `favicon.svg`
|
|
24
|
+
- `favicon.ico`
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Apple Touch Icon
|
|
2
|
+
|
|
3
|
+
When there is an `icon.*` file in the `config` directory at the root of the project, Modern.js will automatically set the file to the [html.appIcon](/configure/app/html/app-icon.md) configuration option for generating the Apple Touch Icon icon under the iOS system.
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
./config
|
|
7
|
+
└── icon.png
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
After the build is completed, you can see the following tags automatically generated in HTML:
|
|
11
|
+
|
|
12
|
+
```html
|
|
13
|
+
<link rel="apple-touch-icon" sizes="180x180" href="/static/image/icon.png" />
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Order
|
|
17
|
+
|
|
18
|
+
When setting up the app icon, Modern.js looks for files in the following order:
|
|
19
|
+
|
|
20
|
+
- `icon.png`
|
|
21
|
+
- `icon.jpg`
|
|
22
|
+
- `icon.jpeg`
|
|
23
|
+
- `icon.svg`
|
|
24
|
+
- `icon.ico`
|