@bleedingdev/modern-js-app-tools 3.5.0-ultramodern.98 → 3.8.1-ultramodern.1
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/builder/generator/getBuilderEnvironments.js +80 -11
- 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 +56 -15
- package/dist/cjs/plugins/analyze/index.js +2 -2
- package/dist/cjs/plugins/analyze/utils.js +3 -2
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/index.js +1 -1
- package/dist/cjs/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.js +94 -18
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/cjs/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/cjs/plugins/initialize/index.js +4 -3
- package/dist/cjs/plugins/serverBuild.js +3 -2
- package/dist/cjs/ultramodern-release-envelope/framework-output.js +109 -57
- package/dist/esm/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm/builder/generator/getBuilderEnvironments.mjs +70 -10
- 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/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm/plugins/initialize/index.mjs +4 -3
- package/dist/esm/plugins/serverBuild.mjs +3 -2
- package/dist/esm/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/esm-node/builder/generator/createBuilderProviderConfig.mjs +5 -1
- package/dist/esm-node/builder/generator/getBuilderEnvironments.mjs +70 -10
- 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/deploy/platforms/cloudflare-output-verifier/index.mjs +1 -1
- package/dist/esm-node/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.mjs +93 -18
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.mjs +1 -0
- package/dist/esm-node/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.mjs +14 -0
- package/dist/esm-node/plugins/initialize/index.mjs +4 -3
- package/dist/esm-node/plugins/serverBuild.mjs +3 -2
- package/dist/esm-node/ultramodern-release-envelope/framework-output.mjs +107 -58
- package/dist/types/builder/generator/getBuilderEnvironments.d.ts +29 -0
- 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/plugins/deploy/platforms/cloudflare-output-verifier/worker-bundles.d.ts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-entry.001-bootstrap-security.d.mts +1 -1
- package/dist/types/plugins/deploy/platforms/templates/cloudflare-worker-mf-ssr-runtime-plugin.d.mts +13 -0
- package/dist/types/types/config/dev.d.ts +6 -0
- package/dist/types/ultramodern-release-envelope/framework-output.d.ts +1 -0
- package/docs/apis/app/commands.md +231 -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-backend-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 +283 -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 +252 -0
- package/docs/community/releases.md +23 -0
- package/docs/community/showcase.md +24 -0
- package/docs/community/team.md +14 -0
- package/docs/configure/app/bff/cross-project.md +20 -0
- package/docs/configure/app/bff/effect.md +313 -0
- package/docs/configure/app/bff/prefix.md +29 -0
- package/docs/configure/app/bff/runtime-framework.md +26 -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 +18 -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 +44 -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/performance/rsdoctor.md +38 -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 +22 -0
- package/docs/configure/app/server/ssr-by-entries.md +25 -0
- package/docs/configure/app/server/ssr.md +80 -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 +116 -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/data-platform.md +116 -0
- package/docs/guides/advanced-features/bff/extend-server.md +120 -0
- package/docs/guides/advanced-features/bff/frameworks.md +243 -0
- package/docs/guides/advanced-features/bff/function.md +318 -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 +267 -0
- package/docs/guides/advanced-features/international/best-practices.md +286 -0
- package/docs/guides/advanced-features/international/configuration.md +228 -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 +173 -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 +51 -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 +47 -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 +516 -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 +524 -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 +40 -0
- package/docs/guides/get-started/quick-start.md +269 -0
- package/docs/guides/get-started/tech-stack.md +91 -0
- package/docs/guides/get-started/ultramodern.md +440 -0
- package/docs/guides/get-started/upgrade.md +118 -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 +182 -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 +954 -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 +290 -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 +63 -22
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
# source.entries
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type Entries = Record<
|
|
7
|
+
string,
|
|
8
|
+
| string
|
|
9
|
+
| {
|
|
10
|
+
entry: string;
|
|
11
|
+
disableMount?: boolean;
|
|
12
|
+
}
|
|
13
|
+
>;
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- **Default:** The entry object calculated based on the directory structure of the current project.
|
|
17
|
+
|
|
18
|
+
Used to configure custom page entries.
|
|
19
|
+
|
|
20
|
+
:::tip When to use
|
|
21
|
+
For most scenarios, the entry automatically generated by Modern.js based on the directory structure can meet the requirements. For details, please refer to [Entry](/guides/concept/entries.md).
|
|
22
|
+
|
|
23
|
+
If you need to customize page entries, you can set them through this option.
|
|
24
|
+
|
|
25
|
+
:::
|
|
26
|
+
|
|
27
|
+
## String
|
|
28
|
+
|
|
29
|
+
When the value of the `entries` object is of type `string`, it represents the file path of the entry module:
|
|
30
|
+
|
|
31
|
+
```ts title="modern.config.ts"
|
|
32
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
33
|
+
|
|
34
|
+
export default defineConfig({
|
|
35
|
+
source: {
|
|
36
|
+
entries: {
|
|
37
|
+
// Specify a new entry named 'my-entry'
|
|
38
|
+
'my-entry': './src/home/test/index.ts',
|
|
39
|
+
},
|
|
40
|
+
disableDefaultEntries: true,
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
By default, the configured entry is equivalent to `App.tsx`, which means that the specified entry file **only needs to export the root component of the application**.
|
|
46
|
+
|
|
47
|
+
For example, the following directory structure:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
.
|
|
51
|
+
├── src
|
|
52
|
+
│ └── entry
|
|
53
|
+
│ ├── chat.tsx
|
|
54
|
+
│ └── home.tsx
|
|
55
|
+
└── package.json
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
The above directory does not conform to the directory structure convention of Modern.js, so Modern.js will not get any default entries when analyzing the directory structure.
|
|
59
|
+
|
|
60
|
+
If you do not want to change the directory structure (such as project migration), you can customize the entry through `source.entries`:
|
|
61
|
+
|
|
62
|
+
```ts title="modern.config.ts"
|
|
63
|
+
export default defineConfig({
|
|
64
|
+
source: {
|
|
65
|
+
entries: {
|
|
66
|
+
home: './src/entry/home.tsx',
|
|
67
|
+
chat: './src/entry/chat.tsx',
|
|
68
|
+
},
|
|
69
|
+
disableDefaultEntries: true,
|
|
70
|
+
},
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
## Object
|
|
75
|
+
|
|
76
|
+
When the value is `Object`, the following attributes can be configured:
|
|
77
|
+
|
|
78
|
+
- `entry`: `string`, the entry file path.
|
|
79
|
+
- `disableMount`: `boolean = false`, disable Modern.js's behavior of automatically generating entry code.
|
|
80
|
+
|
|
81
|
+
```ts title="modern.config.ts"
|
|
82
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
83
|
+
|
|
84
|
+
export default defineConfig({
|
|
85
|
+
source: {
|
|
86
|
+
entries: {
|
|
87
|
+
'my-entry': {
|
|
88
|
+
// entry file path
|
|
89
|
+
entry: './src/my-page/index.tsx',
|
|
90
|
+
disableMount: true,
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
// Disable default entry scanning
|
|
94
|
+
disableDefaultEntries: true,
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Disable entry file generation
|
|
100
|
+
|
|
101
|
+
By default, the configured entry is equivalent to `App.tsx`, and Modern.js will automatically generate an entry file to reference the entry you configured.
|
|
102
|
+
|
|
103
|
+
If you want to disable the logic of Modern.js automatically generating entry files, you can set the `disableMount` property to `true`.
|
|
104
|
+
|
|
105
|
+
```ts title="modern.config.ts"
|
|
106
|
+
export default defineConfig({
|
|
107
|
+
source: {
|
|
108
|
+
entries: {
|
|
109
|
+
'my-entry': {
|
|
110
|
+
entry: './src/my-page/index.tsx',
|
|
111
|
+
disableMount: true,
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
// Disable default entry scanning
|
|
115
|
+
disableDefaultEntries: true,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Conventional Routing
|
|
121
|
+
|
|
122
|
+
If you need to enable conventional routing for a custom entry, you can set `entry` to a directory path:
|
|
123
|
+
|
|
124
|
+
```ts title="modern.config.ts"
|
|
125
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
126
|
+
|
|
127
|
+
export default defineConfig({
|
|
128
|
+
source: {
|
|
129
|
+
entries: {
|
|
130
|
+
// enable conventional routing
|
|
131
|
+
entry_spa: {
|
|
132
|
+
// The entry path of conventional routing must be set to a directory
|
|
133
|
+
entry: './src/about',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
// Disable default entry scanning
|
|
137
|
+
disableDefaultEntries: true,
|
|
138
|
+
},
|
|
139
|
+
});
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
## Entry Merge Rules
|
|
143
|
+
|
|
144
|
+
After setting `source.entries`, if `disableDefaultEntries: true` is not set, Modern.js will merge the custom entry with the entry obtained by analyzing the directory structure.
|
|
145
|
+
|
|
146
|
+
The merge rule is:
|
|
147
|
+
|
|
148
|
+
- Compare the entry paths set by the custom entry setting and the default entry path. When the entry paths are the same, the custom entry will override the default entry.
|
|
149
|
+
|
|
150
|
+
For example, the following directory structure:
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
.
|
|
154
|
+
├── src
|
|
155
|
+
│ ├── chat
|
|
156
|
+
│ │ └── App.tsx
|
|
157
|
+
│ └── home
|
|
158
|
+
│ └── index.ts
|
|
159
|
+
└── package.json
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Modern.js will analyze the `src/` directory and get the default entries `chat` and `home`. When the user configures as follows in the `modern.config.ts` file:
|
|
163
|
+
|
|
164
|
+
```ts title="modern.config.ts"
|
|
165
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
166
|
+
|
|
167
|
+
export default defineConfig({
|
|
168
|
+
source: {
|
|
169
|
+
entries: {
|
|
170
|
+
index: './src/home/index.ts',
|
|
171
|
+
},
|
|
172
|
+
},
|
|
173
|
+
};
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
It can be seen that the path of the custom entry `index` is the same as the path of the default entry `home`. During the merge process, `index` will override `home`, and the final entry is as follows:
|
|
177
|
+
|
|
178
|
+
- `chat -> ./src/chat/App.tsx`
|
|
179
|
+
- `index -> ./src/home/index.ts`
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# source.exclude
|
|
2
|
+
|
|
3
|
+
- **Type:** [RuleSetCondition\[\]](https://rspack.rs/config/module#condition)
|
|
4
|
+
- **Default:** `[]`
|
|
5
|
+
|
|
6
|
+
Specifies JavaScript/TypeScript files that do not need to be compiled. The usage is consistent with [Rule.exclude](https://rspack.rs/config/module#ruleexclude) in Rspack, which supports passing in strings or regular expressions to match the module path.
|
|
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 - source.exclude](https://v2.rsbuild.dev/config/source/exclude).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# source.globalVars
|
|
2
|
+
|
|
3
|
+
- **Type:** `Record<string, JSONValue> | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const defaultGlobalVars = {
|
|
8
|
+
// The environment variable `process.env.NODE_ENV` will be added by default,
|
|
9
|
+
// so you don't need to set it in manually.
|
|
10
|
+
'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV),
|
|
11
|
+
};
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Used to define global variables. It can replace expressions like `process.env.FOO` in your code after compile. Such as:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
console.log(process.env.NODE_ENV);
|
|
18
|
+
|
|
19
|
+
// ⬇️ Turn into being...
|
|
20
|
+
console.log('development');
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
### Example
|
|
24
|
+
|
|
25
|
+
In the following example, the `ENABLE_VCONSOLE` and `APP_CONTEXT` are injected into the code:
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
export default {
|
|
29
|
+
source: {
|
|
30
|
+
globalVars: {
|
|
31
|
+
ENABLE_VCONSOLE: true,
|
|
32
|
+
APP_CONTEXT: { answer: 42 },
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can use them directly in your code:
|
|
39
|
+
|
|
40
|
+
```js
|
|
41
|
+
if (ENABLE_VCONSOLE) {
|
|
42
|
+
// do something
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
console.log(APP_CONTEXT);
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Function Usage
|
|
49
|
+
|
|
50
|
+
- **Type:**
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
type GlobalVarsFn = (
|
|
54
|
+
obj: Record<string, JSONValue>,
|
|
55
|
+
utils: { env: NodeEnv; target: BuilderTarget },
|
|
56
|
+
) => Record<string, JSONValue> | void;
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
You can set `source.globalVars` to a function to dynamically setting some environment variables.
|
|
60
|
+
|
|
61
|
+
For example, dynamically set according to the build target:
|
|
62
|
+
|
|
63
|
+
```js
|
|
64
|
+
export default {
|
|
65
|
+
source: {
|
|
66
|
+
globalVars(obj, { target }) {
|
|
67
|
+
obj['MY_TARGET'] = target === 'node' ? 'server' : 'client';
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Difference with define
|
|
74
|
+
|
|
75
|
+
You can take `source.globalVars` as the syntax sugar of `source.define`, the only difference is that `source.globalVars` will automatically stringify the value, which makes it easier to set the value of global variables. The values of `globalVars` should be JSON-safe to ensure it can be serialized.
|
|
76
|
+
|
|
77
|
+
```js
|
|
78
|
+
export default {
|
|
79
|
+
source: {
|
|
80
|
+
globalVars: {
|
|
81
|
+
'process.env.BUILD_VERSION': '0.0.1',
|
|
82
|
+
'import.meta.foo': { bar: 42 },
|
|
83
|
+
'import.meta.baz': false,
|
|
84
|
+
},
|
|
85
|
+
define: {
|
|
86
|
+
'process.env.BUILD_VERSION': JSON.stringify('0.0.1'),
|
|
87
|
+
'import.meta': {
|
|
88
|
+
foo: JSON.stringify({ bar: 42 }),
|
|
89
|
+
baz: JSON.stringify(false),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Precautions
|
|
97
|
+
|
|
98
|
+
`source.globalVars` injects environment variables through string replacement, so it cannot take effect on dynamic syntaxes such as destructuring.
|
|
99
|
+
|
|
100
|
+
When using destructuring assignment, Modern.js will not be able to determine whether the variable `NODE_ENV` is associated with the expression `process.env.NODE_ENV` to be replaced, so the following usage is invalid:
|
|
101
|
+
|
|
102
|
+
```js
|
|
103
|
+
const { NODE_ENV } = process.env;
|
|
104
|
+
console.log(NODE_ENV);
|
|
105
|
+
// ❌ Won't get a string.
|
|
106
|
+
```
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# source.include
|
|
2
|
+
|
|
3
|
+
- **Type:** [RuleSetCondition\[\]](https://rspack.rs/config/module#condition)
|
|
4
|
+
- **Default value:**
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
const defaultInclude = [
|
|
8
|
+
[{ not: /[\\/]node_modules[\\/]/ }, /\.(?:ts|tsx|jsx|mts|cts)$/],
|
|
9
|
+
];
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
`source.include` is used to specify additional JavaScript files that need to be compiled. By default, the following files will be compiled:
|
|
13
|
+
|
|
14
|
+
- TypeScript and JSX files in any directory, with file extensions matching `.ts`, `.tsx`, `.jsx`, `.mts`, `.cts`.
|
|
15
|
+
- JavaScript files not in the `node_modules` directory, with file extensions matching `.js`, `.mjs`, `.cjs`.
|
|
16
|
+
|
|
17
|
+
:::tip
|
|
18
|
+
Before Rsbuild version 1.4, the default value of `source.include` was:
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
const defaultInclude = [
|
|
22
|
+
[
|
|
23
|
+
{
|
|
24
|
+
and: [APP_ROOT, { not: /[\\/]node_modules[\\/]/ }],
|
|
25
|
+
},
|
|
26
|
+
/\.(?:ts|tsx|jsx|mts|cts)$/,
|
|
27
|
+
],
|
|
28
|
+
];
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The difference from the new version is that `.js`, `.mjs`, `.cjs` files only in the current directory will be compiled.
|
|
32
|
+
:::
|
|
33
|
+
|
|
34
|
+
:::info
|
|
35
|
+
该配置项的使用方式与 Rsbuild 完全一致。详细信息请参考 [Rsbuild - source.include](https://v2.rsbuild.dev/config/source/include)。
|
|
36
|
+
:::
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# source.mainEntryName
|
|
2
|
+
|
|
3
|
+
- **Type:** `string`
|
|
4
|
+
- **Default:** `'index'`
|
|
5
|
+
|
|
6
|
+
This option is used to configure the main entry name of Modern.js.
|
|
7
|
+
|
|
8
|
+
By default, the default main entry name of Modern.js is `index`. When using a single entry or the entry name is the same as the `name` field in `package.json`, the corresponding entry will be used as the main entry. This configuration can be used to modify the name of the main entry.
|
|
9
|
+
|
|
10
|
+
For example, change the main entry name to main:
|
|
11
|
+
|
|
12
|
+
```ts title="modern.config.ts"
|
|
13
|
+
export default defineConfig({
|
|
14
|
+
source: {
|
|
15
|
+
mainEntryName: 'main',
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
After building, the corresponding HTML output path will be changed to `dist/html/index/index.html`.
|
|
21
|
+
|
|
22
|
+
:::info
|
|
23
|
+
When the main entry name is modified, other `**ByEntries` configurations also need to be adjusted to use the modified entry name.
|
|
24
|
+
:::
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# source.preEntry
|
|
2
|
+
|
|
3
|
+
- **Type:** `string | string[]`
|
|
4
|
+
- **Default:** `[]`
|
|
5
|
+
|
|
6
|
+
Add a script before the entry file of each page. This script will be executed before the page code. It can be used to execute global logics, such as injecting polyfills, setting global styles, etc.
|
|
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 - source.preEntry](https://v2.rsbuild.dev/config/source/pre-entry).
|
|
10
|
+
:::
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# source.reactCompiler
|
|
2
|
+
|
|
3
|
+
- **Type:** `boolean | ReactCompilerOptions`
|
|
4
|
+
- **Default:** `undefined` (disabled)
|
|
5
|
+
|
|
6
|
+
Whether to enable [React Compiler](https://react.dev/learn/react-compiler). React Compiler is a build-time tool that optimizes re-rendering performance of React applications through automatic memoization.
|
|
7
|
+
|
|
8
|
+
Modern.js implements this capability based on the Rust-based React Compiler built into Rspack's `builtin:swc-loader` (equivalent to setting SWC's `jsc.transform.reactCompiler`), reusing Rspack's built-in SWC transform chain without introducing Babel.
|
|
9
|
+
|
|
10
|
+
:::tip
|
|
11
|
+
This option is disabled by default. It must be enabled explicitly for any React version, including React 19.
|
|
12
|
+
:::
|
|
13
|
+
|
|
14
|
+
## Example
|
|
15
|
+
|
|
16
|
+
### Enable React Compiler (React 19)
|
|
17
|
+
|
|
18
|
+
```ts title="modern.config.ts"
|
|
19
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
20
|
+
|
|
21
|
+
export default defineConfig({
|
|
22
|
+
source: {
|
|
23
|
+
reactCompiler: true,
|
|
24
|
+
},
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
### Using with React 18
|
|
29
|
+
|
|
30
|
+
The compiled output targets React 19 by default. To use it in React 18 projects, you need to:
|
|
31
|
+
|
|
32
|
+
1. Install [react-compiler-runtime](https://www.npmjs.com/package/react-compiler-runtime) as a **runtime dependency** (the compiled output references it at runtime):
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm add react-compiler-runtime
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
2. Specify the React version via `target`:
|
|
39
|
+
|
|
40
|
+
```ts title="modern.config.ts"
|
|
41
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
42
|
+
|
|
43
|
+
export default defineConfig({
|
|
44
|
+
source: {
|
|
45
|
+
reactCompiler: {
|
|
46
|
+
target: '18',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Customize compilation behavior
|
|
53
|
+
|
|
54
|
+
When passing an object, the options are the same as Rspack's `jsc.transform.reactCompiler`. For example, use `compilationMode: 'annotation'` to only compile functions annotated with the `"use memo"` directive:
|
|
55
|
+
|
|
56
|
+
```ts title="modern.config.ts"
|
|
57
|
+
import { defineConfig } from '@modern-js/app-tools';
|
|
58
|
+
|
|
59
|
+
export default defineConfig({
|
|
60
|
+
source: {
|
|
61
|
+
reactCompiler: {
|
|
62
|
+
compilationMode: 'annotation',
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
For the complete list of options, see [Rsbuild - reactCompiler](https://rsbuild.rs/plugins/list/plugin-react#reactcompiler) and the [React Compiler configuration docs](https://react.dev/reference/react-compiler/configuration).
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# source.transformImport
|
|
2
|
+
|
|
3
|
+
Transform the import path, which can be used to modularly import the subpath of third-party packages. The functionality is similar to [babel-plugin-import](https://www.npmjs.com/package/babel-plugin-import)。
|
|
4
|
+
|
|
5
|
+
- **Type:**
|
|
6
|
+
|
|
7
|
+
```ts
|
|
8
|
+
type TransformImport =
|
|
9
|
+
| false
|
|
10
|
+
| Array<{
|
|
11
|
+
libraryName: string;
|
|
12
|
+
libraryDirectory?: string;
|
|
13
|
+
style?: string | boolean;
|
|
14
|
+
styleLibraryDirectory?: string;
|
|
15
|
+
camelToDashComponentName?: boolean;
|
|
16
|
+
transformToDefaultImport?: boolean;
|
|
17
|
+
customName?: string;
|
|
18
|
+
customStyleName?: string;
|
|
19
|
+
}>
|
|
20
|
+
| Function;
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
- **Default:** `undefined`
|
|
24
|
+
|
|
25
|
+
:::info
|
|
26
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - source.transformImport](https://v2.rsbuild.dev/config/source/transform-import).
|
|
27
|
+
:::
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# splitChunks
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type SplitChunksConfig =
|
|
7
|
+
| (Rspack.OptimizationSplitChunksOptions & {
|
|
8
|
+
preset?: SplitChunksPreset;
|
|
9
|
+
})
|
|
10
|
+
| false;
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`splitChunks` is used to configure Rsbuild's chunk splitting strategy.
|
|
14
|
+
|
|
15
|
+
:::info
|
|
16
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - splitChunks](https://v2.rsbuild.dev/config/split-chunks).
|
|
17
|
+
:::
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# tools.autoprefixer
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
{
|
|
8
|
+
flexbox: 'no-2009',
|
|
9
|
+
// Depends on the browserslist config in the project
|
|
10
|
+
// and the `output.overrideBrowserslist` (higher priority) config
|
|
11
|
+
overrideBrowserslist: browserslist,
|
|
12
|
+
}
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
You can modify the config of [autoprefixer](https://github.com/postcss/autoprefixer) by `tools.autoprefixer`.
|
|
16
|
+
|
|
17
|
+
### Object Type
|
|
18
|
+
|
|
19
|
+
When `tools.autoprefixer` is configured as `Object` type, it is merged with the default config through Object.assign. For example:
|
|
20
|
+
|
|
21
|
+
```js
|
|
22
|
+
export default {
|
|
23
|
+
tools: {
|
|
24
|
+
autoprefixer: {
|
|
25
|
+
flexbox: 'no-2009',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Function Type
|
|
32
|
+
|
|
33
|
+
When `tools.autoprefixer` is a Function, the default config is passed as the first parameter and can be directly modified or returned as the final result. For example:
|
|
34
|
+
|
|
35
|
+
```js
|
|
36
|
+
export default {
|
|
37
|
+
tools: {
|
|
38
|
+
autoprefixer(config) {
|
|
39
|
+
// modify flexbox config
|
|
40
|
+
config.flexbox = 'no-2009';
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# tools.bundlerChain
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type BundlerChainFn = (
|
|
7
|
+
chain: RspackChain,
|
|
8
|
+
utils: ModifyBundlerChainUtils,
|
|
9
|
+
) => Promise<void> | void;
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- **Default:** `undefined`
|
|
13
|
+
|
|
14
|
+
You can modify the Rspack configuration by configuring `tools.bundlerChain` which is type of `Function`. The function receives two parameters, the first is the original bundler chain object, and the second is an object containing some utils.
|
|
15
|
+
|
|
16
|
+
:::tip What is BundlerChain
|
|
17
|
+
|
|
18
|
+
Bundler chain is a chainable configuration tool implemented based on the Rspack configuration API, which you can use to modify Rspack configuration.
|
|
19
|
+
|
|
20
|
+
Configurations modified via bundler chain will work on Rspack builds.
|
|
21
|
+
|
|
22
|
+
:::
|
|
23
|
+
|
|
24
|
+
> `tools.bundlerChain` is executed earlier than tools.rspack and thus will be overridden by changes in tools.rspack.
|
|
25
|
+
|
|
26
|
+
For more information, please refer to [Rsbuild#tools.bundlerChain](https://v2.rsbuild.rs/config/tools/bundler-chain).
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# tools.cssExtract
|
|
2
|
+
|
|
3
|
+
- **Type:**
|
|
4
|
+
|
|
5
|
+
```ts
|
|
6
|
+
type CSSExtractOptions = {
|
|
7
|
+
pluginOptions?: Rspack.CssExtractRspackPluginOptions;
|
|
8
|
+
loaderOptions?: Rspack.CssExtractRspackLoaderOptions;
|
|
9
|
+
};
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
- **Default:**
|
|
13
|
+
|
|
14
|
+
```js
|
|
15
|
+
const defaultOptions = {
|
|
16
|
+
// The loader options
|
|
17
|
+
loaderOptions: {},
|
|
18
|
+
// The plugin options
|
|
19
|
+
pluginOptions: {
|
|
20
|
+
// The default value of cssPath is `static/css`
|
|
21
|
+
// while the default value of cssFilename is `[name].[contenthash:8].css`
|
|
22
|
+
filename: `${cssPath}/${cssFilename}`,
|
|
23
|
+
chunkFilename: `${cssPath}/async/${cssFilename}`,
|
|
24
|
+
ignoreOrder: true,
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
The config of [CssExtractRspackPlugin](https://rspack.rs/plugins/rspack/css-extract-rspack-plugin) can be modified through `tools.cssExtract`.
|
|
30
|
+
|
|
31
|
+
:::info
|
|
32
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.cssExtract](https://v2.rsbuild.dev/config/tools/css-extract).
|
|
33
|
+
:::
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# tools.cssLoader
|
|
2
|
+
|
|
3
|
+
- **Type:** `Object | Function`
|
|
4
|
+
- **Default:**
|
|
5
|
+
|
|
6
|
+
```js
|
|
7
|
+
const defaultOptions = {
|
|
8
|
+
modules: rsbuildConfig.output.cssModules,
|
|
9
|
+
sourceMap: rsbuildConfig.output.sourceMap.css,
|
|
10
|
+
};
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
The config of [css-loader](https://github.com/webpack-contrib/css-loader) can be modified through `tools.cssLoader`.
|
|
14
|
+
|
|
15
|
+
:::info
|
|
16
|
+
The usage of this configuration item is exactly the same as that of Rsbuild. For detailed information, please refer to [Rsbuild - tools.cssLoader](https://v2.rsbuild.dev/config/tools/css-loader).
|
|
17
|
+
:::
|