@modern-js/app-tools 3.6.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 +48 -15
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# output.overrideBrowserslist
|
|
2
|
+
|
|
3
|
+
- **Type:** `string[] | undefined`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const defaultBrowserListMap: Record<RsbuildTarget, string[]> = {
|
|
8
|
+
web: ['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14'],
|
|
9
|
+
node: ['node >= 14'],
|
|
10
|
+
'web-worker': ['chrome >= 87', 'edge >= 88', 'firefox >= 78', 'safari >= 14'],
|
|
11
|
+
};
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Specifies the range of target browsers that the project is compatible with.
|
|
15
|
+
|
|
16
|
+
This value will be used by [SWC](https://github.com/swc-project/swc) and [autoprefixer](https://github.com/postcss/autoprefixer) to identify the JavaScript syntax that need to be transformed and the CSS browser prefixes that need to be added.
|
|
17
|
+
|
|
18
|
+
For other configuration methods and configuration priorities, please refer to the [Browserslist configuration](/guides/advanced-features/compatibility.md).
|
|
19
|
+
|
|
20
|
+
:::info
|
|
21
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - output.overrideBrowserslist](https://v2.rsbuild.dev/config/output/override-browserslist).
|
|
22
|
+
:::
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# output.polyfill
|
|
2
|
+
|
|
3
|
+
- **Type:** `'entry' | 'usage' | 'ua' | 'off'`
|
|
4
|
+
- **Default:** `'entry'`
|
|
5
|
+
|
|
6
|
+
Via `output.polyfill` you can configure how the polyfill is injected.
|
|
7
|
+
|
|
8
|
+
Modern.js also provides a runtime Polyfill solution based on browser [UA](https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Headers/User-Agent) information. For detailed usage instructions, please refer to [Polyfill At Runtime](https://modernjs.dev/en/guides/advanced-features/compatibility.html#polyfill-at-runtime).
|
|
9
|
+
|
|
10
|
+
:::info
|
|
11
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - output.polyfill](https://v2.rsbuild.dev/config/output/polyfill).
|
|
12
|
+
:::
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# output.sourceMap
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type SourceMap =
|
|
7
|
+
| boolean
|
|
8
|
+
| {
|
|
9
|
+
js?: Rspack.Configuration['devtool'];
|
|
10
|
+
css?: boolean;
|
|
11
|
+
};
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
- **Default:**
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const defaultSourceMap = {
|
|
18
|
+
js: isDev ? 'cheap-module-source-map' : 'hidden-source-map',
|
|
19
|
+
css: isDev,
|
|
20
|
+
};
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
When `output.sourceMap` is not configured, the source map generation rules of Modern.js are different from Rsbuild:
|
|
24
|
+
|
|
25
|
+
- In the development mode, JS and CSS source maps are generated for development debugging.
|
|
26
|
+
- In the production mode, JS source maps are generated for stack trace backtracking, and CSS source maps are not generated to provide the best build performance.
|
|
27
|
+
|
|
28
|
+
:::info
|
|
29
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - output.sourceMap](https://v2.rsbuild.dev/config/output/source-map).
|
|
30
|
+
:::
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# output.splitRouteChunks
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean`
|
|
4
|
+
- **Default:** `true`
|
|
5
|
+
|
|
6
|
+
When using convention-based routing, the framework will split js and css based on the route to load on demand. If your project does not want to split js and css based on routes, you can set this option to `false`.
|
|
7
|
+
|
|
8
|
+
Example:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
export default {
|
|
12
|
+
output: {
|
|
13
|
+
splitRouteChunks: false,
|
|
14
|
+
},
|
|
15
|
+
}
|
|
16
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# output.ssg
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean | object`
|
|
4
|
+
- **Default Value:** `undefined`
|
|
5
|
+
|
|
6
|
+
Configuration to enable the application’s SSG (Static Site Generation) feature.
|
|
7
|
+
|
|
8
|
+
:::tip Enabling SSG
|
|
9
|
+
This configuration takes effect only when SSG is enabled. Please read the [Static Site Generation](/guides/basic-features/render/ssg.md) documentation to understand how to enable SSG and its use cases.
|
|
10
|
+
|
|
11
|
+
:::
|
|
12
|
+
|
|
13
|
+
:::info Recommended Reading
|
|
14
|
+
The SSG feature is closely related to routing. It is recommended to understand the [routing solution](/guides/basic-features/routes/routes.md) before using SSG.
|
|
15
|
+
|
|
16
|
+
:::
|
|
17
|
+
|
|
18
|
+
:::info
|
|
19
|
+
|
|
20
|
+
- Use `output.ssg` for single-entry apps.
|
|
21
|
+
- For multi-entry apps, prefer `output.ssgByEntries`.
|
|
22
|
+
- If `output.ssg` is `true` and `output.ssgByEntries` is not set, all routes under all entries are treated as SSG routes.
|
|
23
|
+
|
|
24
|
+
:::
|
|
25
|
+
|
|
26
|
+
## Boolean Type
|
|
27
|
+
|
|
28
|
+
When this configuration is set to `true`, the SSG feature will be enabled for all entries by default. For **manual routing**, the root route of the entry will be rendered. For **conventional routing**, each route in the entry will be rendered.
|
|
29
|
+
|
|
30
|
+
```js
|
|
31
|
+
export default defineConfig({
|
|
32
|
+
output: {
|
|
33
|
+
ssg: true,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
## Object Type
|
|
39
|
+
|
|
40
|
+
When the value type is `Object`, the following attributes can be configured.
|
|
41
|
+
|
|
42
|
+
### Configuration Type
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
type SSGRouteOptions =
|
|
46
|
+
| string
|
|
47
|
+
| {
|
|
48
|
+
url: string;
|
|
49
|
+
headers?: Record<string, any>;
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
type SSGOptions = {
|
|
53
|
+
headers?: Record<string, any>;
|
|
54
|
+
routes?: SSGRouteOptions[];
|
|
55
|
+
};
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Example
|
|
59
|
+
|
|
60
|
+
In the example configuration below, SSG will render the pages corresponding to the `/`, `/about`, and `/user/:id` routes.
|
|
61
|
+
|
|
62
|
+
For the `/user/:id` route, `cookies` will be added to the request headers.
|
|
63
|
+
|
|
64
|
+
```ts title="modern.config.ts"
|
|
65
|
+
export default defineConfig({
|
|
66
|
+
output: {
|
|
67
|
+
ssg: {
|
|
68
|
+
routes: [
|
|
69
|
+
'/',
|
|
70
|
+
'/about',
|
|
71
|
+
{
|
|
72
|
+
url: '/user/modernjs',
|
|
73
|
+
headers: {
|
|
74
|
+
cookies: 'name=modernjs',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
```
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
# output.ssgByEntries
|
|
2
|
+
|
|
3
|
+
- **Type:** `Record<string, boolean | object>`
|
|
4
|
+
- **Default Value:** `undefined`
|
|
5
|
+
|
|
6
|
+
Configure SSG per entry for multi-entry applications.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
|
|
10
|
+
- Use `output.ssg` for single-entry apps.
|
|
11
|
+
- For multi-entry apps, prefer `output.ssgByEntries`.
|
|
12
|
+
- If `output.ssg` is `true` and `output.ssgByEntries` is not set, all routes under all entries are treated as SSG routes.
|
|
13
|
+
|
|
14
|
+
:::
|
|
15
|
+
|
|
16
|
+
## Configuration Type
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
type SSGRouteOptions =
|
|
20
|
+
| string
|
|
21
|
+
| {
|
|
22
|
+
url: string;
|
|
23
|
+
headers?: Record<string, any>;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
type SSGOptions = {
|
|
27
|
+
headers?: Record<string, any>;
|
|
28
|
+
routes?: SSGRouteOptions[];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// ssgByEntries type
|
|
32
|
+
type SSGMultiEntryOptions = Record<string, boolean | SSGOptions>;
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
## Examples
|
|
36
|
+
|
|
37
|
+
### Enable SSG for some entries
|
|
38
|
+
|
|
39
|
+
```ts title="modern.config.ts"
|
|
40
|
+
export default defineConfig({
|
|
41
|
+
output: {
|
|
42
|
+
ssgByEntries: {
|
|
43
|
+
home: true,
|
|
44
|
+
admin: false,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
});
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Configure routes per entry
|
|
51
|
+
|
|
52
|
+
```ts title="modern.config.ts"
|
|
53
|
+
export default defineConfig({
|
|
54
|
+
output: {
|
|
55
|
+
ssgByEntries: {
|
|
56
|
+
home: {
|
|
57
|
+
routes: ['/', '/about', '/user/modernjs'],
|
|
58
|
+
},
|
|
59
|
+
admin: {
|
|
60
|
+
routes: ['/', '/dashboard'],
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Configure headers per entry or route
|
|
68
|
+
|
|
69
|
+
```ts title="modern.config.ts"
|
|
70
|
+
export default defineConfig({
|
|
71
|
+
output: {
|
|
72
|
+
ssgByEntries: {
|
|
73
|
+
home: {
|
|
74
|
+
headers: {
|
|
75
|
+
'x-tt-env': 'ppe_modernjs',
|
|
76
|
+
},
|
|
77
|
+
routes: [
|
|
78
|
+
'/',
|
|
79
|
+
{
|
|
80
|
+
url: '/about',
|
|
81
|
+
headers: {
|
|
82
|
+
from: 'modern-website',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
],
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
```
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# output.svgDefaultExport
|
|
2
|
+
|
|
3
|
+
- **Type:** `'url' | 'component'`
|
|
4
|
+
- **Default:** `'url'`
|
|
5
|
+
|
|
6
|
+
`output.svgDefaultExport` is used to configure the default export type of SVG files.
|
|
7
|
+
|
|
8
|
+
When `output.svgDefaultExport` is set to `url` , the default export of SVG files is the URL of the file. For example:
|
|
9
|
+
|
|
10
|
+
```js
|
|
11
|
+
import logo from './logo.svg';
|
|
12
|
+
|
|
13
|
+
console.log(logo); // => asset url
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
When `output.svgDefaultExport` is set to `component` , the default export of SVG files is the React component of the file. For example:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
import Logo from './logo.svg';
|
|
20
|
+
|
|
21
|
+
console.log(Logo); // => React Component
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
At this time, you can also specify the `?url` query to import the URL, for example:
|
|
25
|
+
|
|
26
|
+
```js
|
|
27
|
+
import logo from './logo.svg?url';
|
|
28
|
+
|
|
29
|
+
console.log(logo); // => asset url
|
|
30
|
+
```
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# output.tempDir
|
|
2
|
+
|
|
3
|
+
- **Type:** `string`
|
|
4
|
+
- **Default:** `''`
|
|
5
|
+
|
|
6
|
+
When developing or building a project, Modern.js generates real Rspack entries and HTML templates, placing them in a temporary directory.
|
|
7
|
+
|
|
8
|
+
If you want to start a project with multiple configurations at the same time, you can use this configuration to generate files in different temporary directories to avoid interference with each other.
|
|
9
|
+
|
|
10
|
+
The configuration can be a relative or absolute path, but paths outside the project should be avoided.
|
|
11
|
+
|
|
12
|
+
Example:
|
|
13
|
+
|
|
14
|
+
```ts
|
|
15
|
+
export default {
|
|
16
|
+
output: {
|
|
17
|
+
tempDir: path.join('node_modules', '.temp-dir'),
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
```
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# performance.buildCache
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type BuildCacheConfig =
|
|
7
|
+
| {
|
|
8
|
+
/**
|
|
9
|
+
* Base directory for the filesystem cache.
|
|
10
|
+
*/
|
|
11
|
+
cacheDirectory?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Set different cache names based on cacheDigest content.
|
|
14
|
+
*/
|
|
15
|
+
cacheDigest?: Array<string | undefined>;
|
|
16
|
+
/**
|
|
17
|
+
* An arrays of additional code dependencies for the build.
|
|
18
|
+
* Rspack will use a hash of each of these items and all dependencies to invalidate the filesystem cache.
|
|
19
|
+
*/
|
|
20
|
+
buildDependencies?: string[];
|
|
21
|
+
}
|
|
22
|
+
| boolean;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Controls the caching behavior during the build process.
|
|
26
|
+
|
|
27
|
+
Modern.js will enable build cache by default to improve the compile speed. You can disable the build cache by setting it to `false`:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
export default {
|
|
31
|
+
performance: {
|
|
32
|
+
buildCache: false,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
:::info
|
|
38
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.buildCache](https://v2.rsbuild.dev/config/performance/build-cache).
|
|
39
|
+
:::
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# performance.chunkSplit
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object`
|
|
4
|
+
- **Default:** `{ strategy: 'split-by-experience' }`
|
|
5
|
+
|
|
6
|
+
`performance.chunkSplit` is used to configure the chunk splitting strategy. The type of `ChunkSplit` is as follows:
|
|
7
|
+
|
|
8
|
+
```ts
|
|
9
|
+
type ForceSplitting = RegExp[] | Record<string, RegExp>;
|
|
10
|
+
|
|
11
|
+
interface BaseChunkSplit {
|
|
12
|
+
strategy?:
|
|
13
|
+
| 'split-by-module'
|
|
14
|
+
| 'split-by-experience'
|
|
15
|
+
| 'all-in-one'
|
|
16
|
+
| 'single-vendor';
|
|
17
|
+
override?: SplitChunks;
|
|
18
|
+
forceSplitting?: ForceSplitting;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface SplitBySize {
|
|
22
|
+
strategy?: 'split-by-size';
|
|
23
|
+
minSize?: number;
|
|
24
|
+
maxSize?: number;
|
|
25
|
+
override?: SplitChunks;
|
|
26
|
+
forceSplitting?: ForceSplitting;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface SplitCustom {
|
|
30
|
+
strategy?: 'custom';
|
|
31
|
+
splitChunks?: SplitChunks;
|
|
32
|
+
forceSplitting?: ForceSplitting;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export type ChunkSplit = BaseChunkSplit | SplitBySize | SplitCustom;
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
:::info
|
|
39
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.chunkSplit](https://v2.rsbuild.dev/config/performance/chunk-split).
|
|
40
|
+
:::
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# performance.dnsPrefetch
|
|
2
|
+
|
|
3
|
+
- **Type:** `undefined | string[]`
|
|
4
|
+
|
|
5
|
+
- **Default:** `undefined`
|
|
6
|
+
|
|
7
|
+
Specifies that the user agent should preemptively perform DNS resolution for the target resource's origin, refer to [dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/rel/dns-prefetch).
|
|
8
|
+
|
|
9
|
+
After this property is set, the domain name can be resolved before the resource is requested, reducing request latency and improving loading performance.
|
|
10
|
+
|
|
11
|
+
See [Using dns-prefetch](https://developer.mozilla.org/en-US/docs/Web/Performance/dns-prefetch) for more details.
|
|
12
|
+
|
|
13
|
+
:::info
|
|
14
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.dnsPrefetch](https://v2.rsbuild.dev/config/performance/dns-prefetch).
|
|
15
|
+
:::
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# performance.preconnect
|
|
2
|
+
|
|
3
|
+
- **Type:** `undefined | Array<string | PreconnectOption>`
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
interface PreconnectOption {
|
|
7
|
+
href: string;
|
|
8
|
+
crossorigin?: boolean;
|
|
9
|
+
}
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- **Default:** `undefined`
|
|
13
|
+
|
|
14
|
+
:::info
|
|
15
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.preconnect](https://v2.rsbuild.dev/config/performance/preconnect).
|
|
16
|
+
:::
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# performance.prefetch
|
|
2
|
+
|
|
3
|
+
- **Type:** `undefined | true | PrefetchOption`
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type IncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
|
|
7
|
+
|
|
8
|
+
type Filter = Array<string | RegExp> | ((filename: string) => boolean);
|
|
9
|
+
|
|
10
|
+
interface PrefetchOption {
|
|
11
|
+
type?: IncludeType;
|
|
12
|
+
include?: Filter;
|
|
13
|
+
exclude?: Filter;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **Default:** `undefined`
|
|
18
|
+
|
|
19
|
+
:::info
|
|
20
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.prefetch](https://v2.rsbuild.dev/config/performance/prefetch).
|
|
21
|
+
:::
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# performance.preload
|
|
2
|
+
|
|
3
|
+
- **Type:** `undefined | true | PreloadOption`
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type IncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
|
|
7
|
+
|
|
8
|
+
type Filter = Array<string | RegExp> | ((filename: string) => boolean);
|
|
9
|
+
|
|
10
|
+
interface PreloadOption {
|
|
11
|
+
type?: IncludeType;
|
|
12
|
+
include?: Filter;
|
|
13
|
+
exclude?: Filter;
|
|
14
|
+
}
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
- **Default:** `undefined`
|
|
18
|
+
|
|
19
|
+
Inject the [`<link rel="preload">`](https://developer.mozilla.org/zh-CN/docs/Web/HTML/Attributes/rel/preload) tags for the static assets generated by Rsbuild.
|
|
20
|
+
|
|
21
|
+
:::info
|
|
22
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.preload](https://v2.rsbuild.dev/config/performance/preload).
|
|
23
|
+
:::
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# performance.printFileSize
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type PrintFileSizeOptions =
|
|
7
|
+
| {
|
|
8
|
+
/**
|
|
9
|
+
* whether to print total size
|
|
10
|
+
*/
|
|
11
|
+
total?: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* whether to print size of each file
|
|
14
|
+
*/
|
|
15
|
+
detail?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* whether to print gzip-compressed size
|
|
18
|
+
*/
|
|
19
|
+
compressed?: boolean;
|
|
20
|
+
}
|
|
21
|
+
| boolean;
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
- **Default:** `true`
|
|
25
|
+
|
|
26
|
+
Whether to print the file sizes after production build.
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
info Production file sizes:
|
|
30
|
+
|
|
31
|
+
File Size Gzipped
|
|
32
|
+
dist/static/js/lib-react.09721b5c.js 152.6 kB 49.0 kB
|
|
33
|
+
dist/html/main/index.html 5.8 kB 2.5 kB
|
|
34
|
+
dist/static/js/main.3568a38e.js 3.5 kB 1.4 kB
|
|
35
|
+
dist/static/css/main.03221f72.css 1.4 kB 741 B
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
:::info
|
|
39
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.printFileSize](https://v2.rsbuild.dev/config/performance/print-file-size).
|
|
40
|
+
:::
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# performance.profile
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean`
|
|
4
|
+
- **Default:** `false`
|
|
5
|
+
|
|
6
|
+
Whether capture timing information for each module, same as the [profile](https://rspack.rs/config/other-options#profile) config of Rspack.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.profile](https://v2.rsbuild.dev/config/performance/profile).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# performance.removeConsole
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean | ConsoleType[]`
|
|
4
|
+
- **Default:** `false`
|
|
5
|
+
|
|
6
|
+
Whether to remove `console.[methodName]` in production build.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.removeConsole](https://v2.rsbuild.dev/config/performance/remove-console).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# performance.removeMomentLocale
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean`
|
|
4
|
+
- **Default:** `false`
|
|
5
|
+
|
|
6
|
+
Whether to remove the locales of [moment.js](https://momentjs.com/).
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - performance.removeMomentLocale](https://v2.rsbuild.dev/config/performance/remove-moment-locale).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# plugins
|
|
2
|
+
|
|
3
|
+
- **Type:** `CliPlugin[]`
|
|
4
|
+
- **Default:** `[]`
|
|
5
|
+
|
|
6
|
+
Used to configure custom Modern.js framework CLI plugins. For information on how to create custom CLI plugins, please refer to [How to Write CLI Plugins](/plugin/introduction.md#cli-plugins).
|
|
7
|
+
|
|
8
|
+
## Note
|
|
9
|
+
|
|
10
|
+
This option is **specifically for configuring framework CLI plugins**. If you need to configure other types of plugins, use the appropriate configuration method:
|
|
11
|
+
|
|
12
|
+
- Use [builderPlugins](/configure/app/builder-plugins.md) for Rsbuild plugins.
|
|
13
|
+
- Use [tools.bundlerChain](/configure/app/tools/bundler-chain.md) for Rspack plugins.
|
|
14
|
+
- Use the [plugins field in runtime config](/configure/app/runtime/plugins.md) for framework Runtime plugins.
|
|
15
|
+
|
|
16
|
+
## Examples
|
|
17
|
+
|
|
18
|
+
Below are examples of using CLI plugins:
|
|
19
|
+
|
|
20
|
+
### Using plugins from npm
|
|
21
|
+
|
|
22
|
+
To use plugins from the npm registry, first install the plugins and then import them in your configuration:
|
|
23
|
+
|
|
24
|
+
```ts title="modern.config.ts"
|
|
25
|
+
import { myPlugin } from 'my-plugin';
|
|
26
|
+
|
|
27
|
+
export default defineConfig({
|
|
28
|
+
plugins: [myPlugin()],
|
|
29
|
+
});
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
### Using local plugins
|
|
33
|
+
|
|
34
|
+
To use plugins from your local repository, import them directly using a relative path:
|
|
35
|
+
|
|
36
|
+
```ts title="modern.config.ts"
|
|
37
|
+
import { myPlugin } from './config/plugin/myPlugin';
|
|
38
|
+
|
|
39
|
+
export default defineConfig({
|
|
40
|
+
plugins: [myPlugin()],
|
|
41
|
+
});
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Plugin configuration
|
|
45
|
+
|
|
46
|
+
If a plugin provides custom configuration options, pass them as parameters to the plugin function:
|
|
47
|
+
|
|
48
|
+
```ts title="modern.config.ts"
|
|
49
|
+
import { myPlugin } from 'my-plugin';
|
|
50
|
+
|
|
51
|
+
export default defineConfig({
|
|
52
|
+
plugins: [
|
|
53
|
+
myPlugin({
|
|
54
|
+
foo: 1,
|
|
55
|
+
bar: 2,
|
|
56
|
+
}),
|
|
57
|
+
],
|
|
58
|
+
});
|
|
59
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# resolve.aliasStrategy
|
|
2
|
+
|
|
3
|
+
- **Type:** `'prefer-tsconfig' | 'prefer-alias'`
|
|
4
|
+
- **Default:** `'prefer-tsconfig'`
|
|
5
|
+
|
|
6
|
+
Set the strategy for path alias resolution, to control the priority relationship between the paths option in `tsconfig.json` and the [resolve.alias](https://v2.rsbuild.rs/config/resolve/alias) option of Rsbuild.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 [Rsbuild - resolve.aliasStrategy](https://v2.rsbuild.dev/config/resolve/alias-strategy)。
|
|
10
|
+
:::
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# resolve.alias
|
|
2
|
+
|
|
3
|
+
- **Type:** `string[]`
|
|
4
|
+
|
|
5
|
+
Create aliases for module paths to simplify import paths or redirect module references.
|
|
6
|
+
|
|
7
|
+
:::info
|
|
8
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - resolve.alias](https://v2.rsbuild.dev/config/resolve/alias).
|
|
9
|
+
:::
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# resolve.conditionNames
|
|
2
|
+
|
|
3
|
+
- **Type:** `string[]`
|
|
4
|
+
- **Default:** Same as Rspack's `resolve.conditionNames`
|
|
5
|
+
|
|
6
|
+
Specifies the condition names used to match entry points in the [exports](https://nodejs.org/api/packages.html#packages_exports) of a package.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - resolve.extensions](https://v2.rsbuild.dev/config/resolve/extensions).
|
|
10
|
+
:::
|
|
11
|
+
:::warning
|
|
12
|
+
Do not enable this configuration option for SSR applications, as it will cause SSR rendering to fail.
|
|
13
|
+
:::
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# resolve.dedupe
|
|
2
|
+
|
|
3
|
+
- **Type:** `string[]`
|
|
4
|
+
|
|
5
|
+
Force Rsbuild to resolve the specified packages from project root, which is useful for deduplicating packages and reducing the bundle size. same as the [resolve.dedupe](https://v2.rsbuild.rs/config/resolve/dedupe) config of Rsbuild.
|
|
6
|
+
|
|
7
|
+
:::info
|
|
8
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - resolve.dedupe](https://v2.rsbuild.dev/config/resolve/dedupe).
|
|
9
|
+
:::
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# resolve.extensions
|
|
2
|
+
|
|
3
|
+
- **Type:** `string[]`
|
|
4
|
+
- **Default:** `['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json']`
|
|
5
|
+
|
|
6
|
+
Automatically resolve file extensions when importing modules. This means you can import files without explicitly writing their extensions.
|
|
7
|
+
|
|
8
|
+
:::info
|
|
9
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - resolve.extensions](https://v2.rsbuild.dev/config/resolve/extensions).
|
|
10
|
+
:::
|
|
11
|
+
:::warning
|
|
12
|
+
Do not enable this configuration option for SSR applications, as it will cause SSR rendering to fail.
|
|
13
|
+
:::
|