@modern-js/main-doc 2.60.0 → 2.60.1
Sign up to get free protection for your applications and to get access to all the features.
- package/docs/en/apis/app/commands.mdx +0 -16
- package/docs/en/community/contributing-guide.mdx +0 -1
- package/docs/en/components/builder.mdx +3 -0
- package/docs/en/components/bundler.mdx +3 -0
- package/docs/en/components/enableSwc.mdx +17 -0
- package/docs/en/components/esbuild.mdx +3 -0
- package/docs/en/components/micro-frontend.mdx +6 -0
- package/docs/en/components/module-federation.mdx +7 -0
- package/docs/en/components/nodeVersion.mdx +26 -0
- package/docs/en/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/en/components/output-polyfill-extend.mdx +1 -0
- package/docs/en/components/prerequisites.mdx +1 -1
- package/docs/en/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/en/components/rsbuild.mdx +3 -0
- package/docs/en/components/rspack.mdx +3 -0
- package/docs/en/components/rspackPrecautions.mdx +6 -0
- package/docs/en/components/rspackTip.mdx +7 -0
- package/docs/en/components/swc.mdx +3 -0
- package/docs/en/configure/app/dev/asset-prefix.mdx +12 -2
- package/docs/en/configure/app/dev/before-start-url.mdx +14 -2
- package/docs/en/configure/app/dev/client.mdx +20 -16
- package/docs/en/configure/app/dev/hmr.mdx +8 -2
- package/docs/en/configure/app/dev/host.mdx +15 -2
- package/docs/en/configure/app/dev/https.mdx +71 -2
- package/docs/en/configure/app/dev/live-reload.mdx +3 -15
- package/docs/en/configure/app/dev/port.mdx +18 -2
- package/docs/en/configure/app/dev/progress-bar.mdx +17 -2
- package/docs/en/configure/app/dev/setup-middlewares.mdx +25 -39
- package/docs/en/configure/app/dev/start-url.mdx +46 -2
- package/docs/en/configure/app/dev/watch-files.mdx +5 -39
- package/docs/en/configure/app/dev/write-to-disk.mdx +4 -27
- package/docs/en/configure/app/experiments/lazy-compilation.mdx +84 -2
- package/docs/en/configure/app/experiments/source-build.mdx +28 -3
- package/docs/en/configure/app/html/app-icon.mdx +48 -2
- package/docs/en/configure/app/html/crossorigin.mdx +8 -2
- package/docs/en/configure/app/html/disable-html-folder.mdx +35 -2
- package/docs/en/configure/app/html/favicon-by-entries.mdx +29 -2
- package/docs/en/configure/app/html/favicon.mdx +14 -2
- package/docs/en/configure/app/html/inject-by-entries.mdx +29 -2
- package/docs/en/configure/app/html/inject.mdx +8 -2
- package/docs/en/configure/app/html/meta-by-entries.mdx +41 -2
- package/docs/en/configure/app/html/meta.mdx +22 -2
- package/docs/en/configure/app/html/mount-id.mdx +8 -2
- package/docs/en/configure/app/html/script-loading.mdx +8 -2
- package/docs/en/configure/app/html/tags-by-entries.mdx +37 -2
- package/docs/en/configure/app/html/tags.mdx +13 -2
- package/docs/en/configure/app/html/template-by-entries.mdx +26 -2
- package/docs/en/configure/app/html/template-parameters-by-entries.mdx +28 -2
- package/docs/en/configure/app/html/template-parameters.mdx +31 -2
- package/docs/en/configure/app/html/template.mdx +8 -2
- package/docs/en/configure/app/html/title-by-entries.mdx +30 -2
- package/docs/en/configure/app/html/title.mdx +16 -2
- package/docs/en/configure/app/output/asset-prefix.mdx +12 -2
- package/docs/en/configure/app/output/assets-retry.mdx +72 -2
- package/docs/en/configure/app/output/charset.mdx +8 -2
- package/docs/en/configure/app/output/clean-dist-path.mdx +13 -2
- package/docs/en/configure/app/output/convert-to-rem.mdx +76 -2
- package/docs/en/configure/app/output/copy.mdx +5 -2
- package/docs/en/configure/app/output/css-module-local-ident-name.mdx +14 -2
- package/docs/en/configure/app/output/css-modules.mdx +46 -2
- package/docs/en/configure/app/output/data-uri-limit.mdx +24 -2
- package/docs/en/configure/app/output/disable-css-extract.mdx +9 -2
- package/docs/en/configure/app/output/disable-css-module-extension.mdx +52 -2
- package/docs/en/configure/app/output/disable-filename-hash.mdx +9 -2
- package/docs/en/configure/app/output/disable-inline-runtime-chunk.mdx +38 -2
- package/docs/en/configure/app/output/disable-minimize.mdx +7 -2
- package/docs/en/configure/app/output/disable-source-map.mdx +24 -2
- package/docs/en/configure/app/output/disable-svgr.mdx +13 -2
- package/docs/en/configure/app/output/disable-ts-checker.mdx +46 -2
- package/docs/en/configure/app/output/dist-path.mdx +39 -2
- package/docs/en/configure/app/output/enable-asset-fallback.mdx +29 -2
- package/docs/en/configure/app/output/enable-asset-manifest.mdx +33 -2
- package/docs/en/configure/app/output/enable-css-module-tsdeclaration.mdx +25 -2
- package/docs/en/configure/app/output/enable-inline-scripts.mdx +15 -2
- package/docs/en/configure/app/output/enable-inline-styles.mdx +15 -2
- package/docs/en/configure/app/output/enable-latest-decorators.mdx +7 -2
- package/docs/en/configure/app/output/externals.mdx +18 -2
- package/docs/en/configure/app/output/filename-hash.mdx +3 -27
- package/docs/en/configure/app/output/filename.mdx +47 -2
- package/docs/en/configure/app/output/inject-styles.mdx +15 -0
- package/docs/en/configure/app/output/inline-scripts.mdx +34 -0
- package/docs/en/configure/app/output/inline-styles.mdx +34 -0
- package/docs/en/configure/app/output/legal-comments.mdx +16 -2
- package/docs/en/configure/app/output/minify.mdx +27 -0
- package/docs/en/configure/app/output/override-browserslist.mdx +18 -2
- package/docs/en/configure/app/output/polyfill.mdx +12 -2
- package/docs/en/configure/app/output/source-map.mdx +30 -0
- package/docs/en/configure/app/output/ssg.mdx +20 -17
- package/docs/en/configure/app/output/svg-default-export.mdx +27 -2
- package/docs/en/configure/app/performance/build-cache.mdx +78 -2
- package/docs/en/configure/app/performance/bundle-analyze.mdx +18 -2
- package/docs/en/configure/app/performance/chunk-split.mdx +38 -2
- package/docs/en/configure/app/performance/dns-prefetch.mdx +13 -2
- package/docs/en/configure/app/performance/preconnect.mdx +14 -2
- package/docs/en/configure/app/performance/prefetch.mdx +19 -2
- package/docs/en/configure/app/performance/preload.mdx +21 -2
- package/docs/en/configure/app/performance/print-file-size.mdx +38 -2
- package/docs/en/configure/app/performance/profile.mdx +8 -2
- package/docs/en/configure/app/performance/remove-console.mdx +8 -2
- package/docs/en/configure/app/performance/remove-moment-locale.mdx +8 -2
- package/docs/en/configure/app/performance/transform-lodash.mdx +42 -2
- package/docs/en/configure/app/plugins.mdx +1 -1
- package/docs/en/configure/app/security/check-syntax.mdx +66 -2
- package/docs/en/configure/app/security/nonce.mdx +13 -2
- package/docs/en/configure/app/security/sri.mdx +19 -2
- package/docs/en/configure/app/server/port.mdx +5 -0
- package/docs/en/configure/app/server/ssr.mdx +10 -9
- package/docs/en/configure/app/source/alias-strategy.mdx +8 -2
- package/docs/en/configure/app/source/alias.mdx +17 -2
- package/docs/en/configure/app/source/config-dir.mdx +1 -1
- package/docs/en/configure/app/source/decorators.mdx +8 -21
- package/docs/en/configure/app/source/define.mdx +14 -2
- package/docs/en/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/en/configure/app/source/entries-dir.mdx +1 -1
- package/docs/en/configure/app/source/exclude.mdx +8 -2
- package/docs/en/configure/app/source/global-vars.mdx +103 -2
- package/docs/en/configure/app/source/include.mdx +19 -2
- package/docs/en/configure/app/source/mainEntryName.mdx +1 -1
- package/docs/en/configure/app/source/module-scopes.mdx +62 -2
- package/docs/en/configure/app/source/pre-entry.mdx +8 -2
- package/docs/en/configure/app/source/resolve-extension-prefix.mdx +48 -2
- package/docs/en/configure/app/source/resolve-main-fields.mdx +39 -2
- package/docs/en/configure/app/source/transform-import.mdx +56 -2
- package/docs/en/configure/app/tools/autoprefixer.mdx +41 -2
- package/docs/en/configure/app/tools/babel.mdx +218 -2
- package/docs/en/configure/app/tools/bundler-chain.mdx +23 -2
- package/docs/en/configure/app/tools/css-extract.mdx +31 -2
- package/docs/en/configure/app/tools/css-loader.mdx +14 -2
- package/docs/en/configure/app/tools/dev-server.mdx +435 -2
- package/docs/en/configure/app/tools/esbuild.mdx +1 -1
- package/docs/en/configure/app/tools/html-plugin.mdx +21 -2
- package/docs/en/configure/app/tools/less.mdx +78 -2
- package/docs/en/configure/app/tools/minify-css.mdx +50 -2
- package/docs/en/configure/app/tools/postcss.mdx +30 -2
- package/docs/en/configure/app/tools/pug.mdx +47 -2
- package/docs/en/configure/app/tools/rspack.mdx +8 -2
- package/docs/en/configure/app/tools/sass.mdx +75 -2
- package/docs/en/configure/app/tools/style-loader.mdx +8 -2
- package/docs/en/configure/app/tools/styled-components.mdx +48 -2
- package/docs/en/configure/app/tools/swc.mdx +33 -2
- package/docs/en/configure/app/tools/terser.mdx +49 -2
- package/docs/en/configure/app/tools/ts-checker.mdx +49 -2
- package/docs/en/configure/app/tools/ts-loader.mdx +63 -2
- package/docs/en/configure/app/tools/webpack-chain.mdx +239 -2
- package/docs/en/configure/app/tools/webpack.mdx +295 -2
- package/docs/en/guides/advanced-features/_meta.json +0 -1
- package/docs/en/guides/advanced-features/rspack-start.mdx +2 -2
- package/docs/en/guides/basic-features/css/css-modules.mdx +2 -2
- package/docs/en/guides/basic-features/output-files.mdx +1 -1
- package/docs/en/guides/basic-features/render/ssg.mdx +1 -1
- package/docs/en/guides/concept/builder.mdx +1 -1
- package/docs/en/guides/get-started/glossary.mdx +7 -7
- package/docs/en/guides/get-started/quick-start.mdx +1 -1
- package/docs/en/guides/topic-detail/_meta.json +0 -6
- package/docs/en/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -1
- package/docs/en/guides/topic-detail/model/quick-start.mdx +5 -0
- package/docs/en/guides/troubleshooting/builder.mdx +2 -2
- package/docs/en/plugin/cli-plugins/plugin-swc.mdx +4 -4
- package/docs/en/plugin/rsbuild-plugins/plugin-esbuild.mdx +4 -4
- package/docs/zh/apis/app/commands.mdx +0 -18
- package/docs/zh/community/contributing-guide.mdx +0 -1
- package/docs/zh/components/builder.mdx +3 -0
- package/docs/zh/components/bundler.mdx +4 -0
- package/docs/zh/components/enableSwc.mdx +17 -0
- package/docs/zh/components/esbuild.mdx +3 -0
- package/docs/zh/components/micro-frontend.mdx +6 -0
- package/docs/zh/components/module-federation.mdx +7 -0
- package/docs/zh/components/nodeVersion.mdx +28 -0
- package/docs/zh/components/output-asset-prefix-extend.mdx +0 -0
- package/docs/zh/components/output-polyfill-extend.mdx +1 -0
- package/docs/zh/components/prerequisites.mdx +1 -1
- package/docs/zh/components/rsbuild-config-tooltip.mdx +5 -0
- package/docs/zh/components/rsbuild.mdx +3 -0
- package/docs/zh/components/rspack.mdx +3 -0
- package/docs/zh/components/rspackPrecautions.mdx +6 -0
- package/docs/zh/components/rspackTip.mdx +7 -0
- package/docs/zh/components/swc.mdx +3 -0
- package/docs/zh/configure/app/dev/asset-prefix.mdx +12 -2
- package/docs/zh/configure/app/dev/before-start-url.mdx +14 -2
- package/docs/zh/configure/app/dev/client.mdx +20 -16
- package/docs/zh/configure/app/dev/hmr.mdx +8 -2
- package/docs/zh/configure/app/dev/host.mdx +15 -2
- package/docs/zh/configure/app/dev/https.mdx +72 -2
- package/docs/zh/configure/app/dev/live-reload.mdx +3 -15
- package/docs/zh/configure/app/dev/port.mdx +18 -2
- package/docs/zh/configure/app/dev/progress-bar.mdx +17 -2
- package/docs/zh/configure/app/dev/setup-middlewares.mdx +26 -39
- package/docs/zh/configure/app/dev/start-url.mdx +47 -2
- package/docs/zh/configure/app/dev/watch-files.mdx +5 -39
- package/docs/zh/configure/app/dev/write-to-disk.mdx +3 -26
- package/docs/zh/configure/app/experiments/lazy-compilation.mdx +84 -2
- package/docs/zh/configure/app/experiments/source-build.mdx +29 -2
- package/docs/zh/configure/app/html/app-icon.mdx +48 -2
- package/docs/zh/configure/app/html/crossorigin.mdx +9 -2
- package/docs/zh/configure/app/html/disable-html-folder.mdx +34 -2
- package/docs/zh/configure/app/html/favicon-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/favicon.mdx +15 -2
- package/docs/zh/configure/app/html/inject-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/inject.mdx +8 -2
- package/docs/zh/configure/app/html/meta-by-entries.mdx +41 -2
- package/docs/zh/configure/app/html/meta.mdx +22 -2
- package/docs/zh/configure/app/html/mount-id.mdx +8 -2
- package/docs/zh/configure/app/html/script-loading.mdx +8 -2
- package/docs/zh/configure/app/html/tags-by-entries.mdx +37 -2
- package/docs/zh/configure/app/html/tags.mdx +13 -2
- package/docs/zh/configure/app/html/template-by-entries.mdx +26 -2
- package/docs/zh/configure/app/html/template-parameters-by-entries.mdx +29 -2
- package/docs/zh/configure/app/html/template-parameters.mdx +31 -2
- package/docs/zh/configure/app/html/template.mdx +8 -2
- package/docs/zh/configure/app/html/title-by-entries.mdx +30 -2
- package/docs/zh/configure/app/html/title.mdx +16 -2
- package/docs/zh/configure/app/output/asset-prefix.mdx +12 -2
- package/docs/zh/configure/app/output/assets-retry.mdx +72 -2
- package/docs/zh/configure/app/output/charset.mdx +8 -2
- package/docs/zh/configure/app/output/clean-dist-path.mdx +13 -2
- package/docs/zh/configure/app/output/convert-to-rem.mdx +77 -2
- package/docs/zh/configure/app/output/copy.mdx +6 -2
- package/docs/zh/configure/app/output/css-module-local-ident-name.mdx +14 -2
- package/docs/zh/configure/app/output/css-modules.mdx +46 -2
- package/docs/zh/configure/app/output/data-uri-limit.mdx +24 -2
- package/docs/zh/configure/app/output/disable-css-extract.mdx +9 -2
- package/docs/zh/configure/app/output/disable-css-module-extension.mdx +52 -2
- package/docs/zh/configure/app/output/disable-filename-hash.mdx +9 -2
- package/docs/zh/configure/app/output/disable-inline-runtime-chunk.mdx +38 -2
- package/docs/zh/configure/app/output/disable-minimize.mdx +7 -2
- package/docs/zh/configure/app/output/disable-source-map.mdx +24 -2
- package/docs/zh/configure/app/output/disable-svgr.mdx +14 -2
- package/docs/zh/configure/app/output/disable-ts-checker.mdx +46 -2
- package/docs/zh/configure/app/output/dist-path.mdx +39 -2
- package/docs/zh/configure/app/output/enable-asset-fallback.mdx +29 -2
- package/docs/zh/configure/app/output/enable-asset-manifest.mdx +33 -2
- package/docs/zh/configure/app/output/enable-css-module-tsdeclaration.mdx +25 -2
- package/docs/zh/configure/app/output/enable-inline-scripts.mdx +15 -2
- package/docs/zh/configure/app/output/enable-inline-styles.mdx +15 -2
- package/docs/zh/configure/app/output/enable-latest-decorators.mdx +7 -2
- package/docs/zh/configure/app/output/externals.mdx +18 -2
- package/docs/zh/configure/app/output/filename-hash.mdx +4 -27
- package/docs/zh/configure/app/output/filename.mdx +47 -2
- package/docs/zh/configure/app/output/inject-styles.mdx +15 -0
- package/docs/zh/configure/app/output/inline-scripts.mdx +34 -0
- package/docs/zh/configure/app/output/inline-styles.mdx +34 -0
- package/docs/zh/configure/app/output/legal-comments.mdx +16 -2
- package/docs/zh/configure/app/output/minify.mdx +27 -0
- package/docs/zh/configure/app/output/override-browserslist.mdx +20 -2
- package/docs/zh/configure/app/output/polyfill.mdx +12 -2
- package/docs/zh/configure/app/output/source-map.mdx +30 -0
- package/docs/zh/configure/app/output/ssg.mdx +19 -15
- package/docs/zh/configure/app/output/svg-default-export.mdx +27 -2
- package/docs/zh/configure/app/performance/build-cache.mdx +77 -2
- package/docs/zh/configure/app/performance/bundle-analyze.mdx +18 -2
- package/docs/zh/configure/app/performance/chunk-split.mdx +38 -2
- package/docs/zh/configure/app/performance/dns-prefetch.mdx +13 -2
- package/docs/zh/configure/app/performance/preconnect.mdx +14 -2
- package/docs/zh/configure/app/performance/prefetch.mdx +19 -2
- package/docs/zh/configure/app/performance/preload.mdx +21 -2
- package/docs/zh/configure/app/performance/print-file-size.mdx +38 -2
- package/docs/zh/configure/app/performance/profile.mdx +8 -2
- package/docs/zh/configure/app/performance/remove-console.mdx +8 -2
- package/docs/zh/configure/app/performance/remove-moment-locale.mdx +8 -2
- package/docs/zh/configure/app/performance/transform-lodash.mdx +42 -2
- package/docs/zh/configure/app/plugins.mdx +1 -1
- package/docs/zh/configure/app/security/check-syntax.mdx +66 -2
- package/docs/zh/configure/app/security/nonce.mdx +13 -2
- package/docs/zh/configure/app/security/sri.mdx +19 -2
- package/docs/zh/configure/app/server/port.mdx +5 -0
- package/docs/zh/configure/app/server/ssr.mdx +10 -9
- package/docs/zh/configure/app/source/alias-strategy.mdx +8 -2
- package/docs/zh/configure/app/source/alias.mdx +17 -2
- package/docs/zh/configure/app/source/config-dir.mdx +1 -1
- package/docs/zh/configure/app/source/decorators.mdx +8 -20
- package/docs/zh/configure/app/source/define.mdx +14 -2
- package/docs/zh/configure/app/source/enable-async-entry.mdx +1 -1
- package/docs/zh/configure/app/source/entries-dir.mdx +1 -1
- package/docs/zh/configure/app/source/exclude.mdx +8 -2
- package/docs/zh/configure/app/source/global-vars.mdx +102 -2
- package/docs/zh/configure/app/source/include.mdx +19 -2
- package/docs/zh/configure/app/source/mainEntryName.mdx +1 -1
- package/docs/zh/configure/app/source/module-scopes.mdx +62 -2
- package/docs/zh/configure/app/source/pre-entry.mdx +8 -2
- package/docs/zh/configure/app/source/resolve-extension-prefix.mdx +50 -2
- package/docs/zh/configure/app/source/resolve-main-fields.mdx +39 -2
- package/docs/zh/configure/app/source/transform-import.mdx +56 -2
- package/docs/zh/configure/app/tools/autoprefixer.mdx +41 -2
- package/docs/zh/configure/app/tools/babel.mdx +218 -2
- package/docs/zh/configure/app/tools/bundler-chain.mdx +26 -2
- package/docs/zh/configure/app/tools/css-extract.mdx +28 -2
- package/docs/zh/configure/app/tools/css-loader.mdx +15 -2
- package/docs/zh/configure/app/tools/dev-server.mdx +435 -2
- package/docs/zh/configure/app/tools/esbuild.mdx +1 -1
- package/docs/zh/configure/app/tools/html-plugin.mdx +21 -2
- package/docs/zh/configure/app/tools/less.mdx +79 -2
- package/docs/zh/configure/app/tools/minify-css.mdx +50 -2
- package/docs/zh/configure/app/tools/postcss.mdx +31 -2
- package/docs/zh/configure/app/tools/pug.mdx +47 -2
- package/docs/zh/configure/app/tools/rspack.mdx +8 -2
- package/docs/zh/configure/app/tools/sass.mdx +73 -2
- package/docs/zh/configure/app/tools/style-loader.mdx +8 -2
- package/docs/zh/configure/app/tools/styled-components.mdx +47 -2
- package/docs/zh/configure/app/tools/swc.mdx +33 -2
- package/docs/zh/configure/app/tools/terser.mdx +49 -2
- package/docs/zh/configure/app/tools/ts-checker.mdx +49 -2
- package/docs/zh/configure/app/tools/ts-loader.mdx +63 -2
- package/docs/zh/configure/app/tools/webpack-chain.mdx +243 -2
- package/docs/zh/configure/app/tools/webpack.mdx +295 -2
- package/docs/zh/guides/advanced-features/_meta.json +0 -1
- package/docs/zh/guides/advanced-features/rspack-start.mdx +2 -2
- package/docs/zh/guides/basic-features/css/css-modules.mdx +1 -1
- package/docs/zh/guides/basic-features/output-files.mdx +2 -2
- package/docs/zh/guides/concept/builder.mdx +1 -1
- package/docs/zh/guides/get-started/glossary.mdx +7 -7
- package/docs/zh/guides/get-started/quick-start.mdx +1 -1
- package/docs/zh/guides/topic-detail/_meta.json +0 -6
- package/docs/zh/guides/topic-detail/micro-frontend/c01-introduction.mdx +1 -1
- package/docs/zh/guides/topic-detail/model/quick-start.mdx +5 -0
- package/docs/zh/guides/troubleshooting/builder.mdx +2 -2
- package/docs/zh/plugin/cli-plugins/plugin-swc.mdx +4 -4
- package/docs/zh/plugin/rsbuild-plugins/plugin-esbuild.mdx +6 -6
- package/package.json +6 -11
- package/src/components/RsbuildLink/index.tsx +19 -0
- /package/docs/en/configure/app/output/{splitRouteChunks.mdx → split-route-chunks.mdx} +0 -0
- /package/docs/zh/configure/app/output/{splitRouteChunks.mdx → split-route-chunks.mdx} +0 -0
@@ -4,6 +4,222 @@ title: babel
|
|
4
4
|
|
5
5
|
# tools.babel
|
6
6
|
|
7
|
-
|
7
|
+
- **Type:** `Object | Function`
|
8
|
+
- **Default:** `undefined`
|
8
9
|
|
9
|
-
|
10
|
+
With `tools.babel` you can modify the options of [babel-loader](https://github.com/babel/babel-loader).
|
11
|
+
|
12
|
+
### Usage Scenarios
|
13
|
+
|
14
|
+
Please note the limitations of `tools.babel` in the following usage scenarios:
|
15
|
+
|
16
|
+
- Rspack scenario: When using Rspack as the bundler, using the `tools.babel` option will significantly slow down the Rspack's build speed. This is because Rspack defaults to using SWC for compilation, and configuring Babel will cause the code to be compiled twice, resulting in additional compilation overhead.
|
17
|
+
- webpack + SWC scenario: When using webpack as the bundler, if you use SWC plugin for code compilation, the `tools.babel` option will not take effect.
|
18
|
+
|
19
|
+
### Function Type
|
20
|
+
|
21
|
+
When `tools.babel` is of type `Function`, the default Babel configuration will be passed as the first parameter. You can directly modify the configuration object or return an object as the final `babel-loader` configuration.
|
22
|
+
|
23
|
+
```js
|
24
|
+
export default {
|
25
|
+
tools: {
|
26
|
+
babel(config) {
|
27
|
+
// Add a Babel plugin
|
28
|
+
// note: the plugin have been added to the default config to support antd load on demand
|
29
|
+
config.plugins.push([
|
30
|
+
'babel-plugin-import',
|
31
|
+
{
|
32
|
+
libraryName: 'xxx-components',
|
33
|
+
libraryDirectory: 'es',
|
34
|
+
style: true,
|
35
|
+
},
|
36
|
+
]);
|
37
|
+
},
|
38
|
+
},
|
39
|
+
};
|
40
|
+
```
|
41
|
+
|
42
|
+
The second parameter of the `tools.babel` function provides some more convenient utility functions. Please continue reading the documentation below.
|
43
|
+
|
44
|
+
:::tip
|
45
|
+
The above example is just for reference, usually you don't need to manually configure `babel-plugin-import`, because Modern.js already provides a more general `source.transformImport` configuration.
|
46
|
+
:::
|
47
|
+
|
48
|
+
### Object Type
|
49
|
+
|
50
|
+
When `tools.babel`'s type is `Object`, the config will be shallow merged with default config by `Object.assign`.
|
51
|
+
|
52
|
+
:::caution
|
53
|
+
Note that `Object.assign` is a shallow copy and will completely overwrite the built-in `presets` or `plugins` array, please use it with caution.
|
54
|
+
:::
|
55
|
+
|
56
|
+
```js
|
57
|
+
export default {
|
58
|
+
tools: {
|
59
|
+
babel: {
|
60
|
+
plugins: [
|
61
|
+
[
|
62
|
+
'babel-plugin-import',
|
63
|
+
{
|
64
|
+
libraryName: 'xxx-components',
|
65
|
+
libraryDirectory: 'es',
|
66
|
+
style: true,
|
67
|
+
},
|
68
|
+
],
|
69
|
+
],
|
70
|
+
},
|
71
|
+
},
|
72
|
+
};
|
73
|
+
```
|
74
|
+
|
75
|
+
### Util Functions
|
76
|
+
|
77
|
+
When `tools.babel` is a Function, the tool functions available for the second parameter are as follows:
|
78
|
+
|
79
|
+
#### addPlugins
|
80
|
+
|
81
|
+
- **Type:** `(plugins: BabelPlugin[]) => void`
|
82
|
+
|
83
|
+
Add some Babel plugins. For example:
|
84
|
+
|
85
|
+
```js
|
86
|
+
export default {
|
87
|
+
tools: {
|
88
|
+
babel(config, { addPlugins }) {
|
89
|
+
addPlugins([
|
90
|
+
[
|
91
|
+
'babel-plugin-import',
|
92
|
+
{
|
93
|
+
libraryName: 'xxx-components',
|
94
|
+
libraryDirectory: 'es',
|
95
|
+
style: true,
|
96
|
+
},
|
97
|
+
],
|
98
|
+
]);
|
99
|
+
},
|
100
|
+
},
|
101
|
+
};
|
102
|
+
```
|
103
|
+
|
104
|
+
#### addPresets
|
105
|
+
|
106
|
+
- **Type:** `(presets: BabelPlugin[]) => void`
|
107
|
+
|
108
|
+
Add Babel preset configuration. (No need to add presets in most cases)
|
109
|
+
|
110
|
+
```js
|
111
|
+
export default {
|
112
|
+
tools: {
|
113
|
+
babel(config, { addPresets }) {
|
114
|
+
addPresets(['@babel/preset-env']);
|
115
|
+
},
|
116
|
+
},
|
117
|
+
};
|
118
|
+
```
|
119
|
+
|
120
|
+
#### removePlugins
|
121
|
+
|
122
|
+
- **Type:** `(plugins: string | string[]) => void`
|
123
|
+
|
124
|
+
To remove the Babel plugin, just pass in the name of the plugin to be removed, you can pass in a single string or an array of strings.
|
125
|
+
|
126
|
+
```js
|
127
|
+
export default {
|
128
|
+
tools: {
|
129
|
+
babel(config, { removePlugins }) {
|
130
|
+
removePlugins('babel-plugin-import');
|
131
|
+
},
|
132
|
+
},
|
133
|
+
};
|
134
|
+
```
|
135
|
+
|
136
|
+
#### removePresets
|
137
|
+
|
138
|
+
- **Type:** `(presets: string | string[]) => void`
|
139
|
+
|
140
|
+
To remove the Babel preset configuration, pass in the name of the preset to be removed, you can pass in a single string or an array of strings.
|
141
|
+
|
142
|
+
```js
|
143
|
+
export default {
|
144
|
+
tools: {
|
145
|
+
babel(config, { removePresets }) {
|
146
|
+
removePresets('@babel/preset-env');
|
147
|
+
},
|
148
|
+
},
|
149
|
+
};
|
150
|
+
```
|
151
|
+
|
152
|
+
#### modifyPresetEnvOptions
|
153
|
+
|
154
|
+
- **Type:** `(options: PresetEnvOptions) => void`
|
155
|
+
|
156
|
+
Modify the configuration of [@babel/preset-env](https://babeljs.io/docs/en/babel-preset-env), the configuration you pass in will be shallowly merged with default config. For example:
|
157
|
+
|
158
|
+
```js
|
159
|
+
export default {
|
160
|
+
tools: {
|
161
|
+
babel(config, { modifyPresetEnvOptions }) {
|
162
|
+
modifyPresetEnvOptions({
|
163
|
+
targets: "last 2 versions",
|
164
|
+
});
|
165
|
+
},
|
166
|
+
},
|
167
|
+
};
|
168
|
+
```
|
169
|
+
|
170
|
+
```js
|
171
|
+
export default {
|
172
|
+
tools: {
|
173
|
+
babel(config, { modifyPresetEnvOptions }) {
|
174
|
+
modifyPresetEnvOptions({
|
175
|
+
targets: {
|
176
|
+
chrome: "58",
|
177
|
+
ie: "11"
|
178
|
+
}
|
179
|
+
});
|
180
|
+
},
|
181
|
+
},
|
182
|
+
};
|
183
|
+
```
|
184
|
+
|
185
|
+
#### modifyPresetReactOptions
|
186
|
+
|
187
|
+
- **Type:** `(options: PresetReactOptions) => void`
|
188
|
+
|
189
|
+
Modify the configuration of [@babel/preset-react](https://babeljs.io/docs/en/babel-preset-react), the configuration you pass in will be shallowly merged with default config. For example:
|
190
|
+
|
191
|
+
```js
|
192
|
+
export default {
|
193
|
+
tools: {
|
194
|
+
babel(config, { modifyPresetReactOptions }) {
|
195
|
+
modifyPresetReactOptions({
|
196
|
+
pragma: 'React.createElement',
|
197
|
+
});
|
198
|
+
},
|
199
|
+
},
|
200
|
+
};
|
201
|
+
```
|
202
|
+
|
203
|
+
#### addIncludes
|
204
|
+
|
205
|
+
Deprecated, please use [source.include](https://modernjs.dev/en/configure/app/source/include.html) instead, both have the same functionality.
|
206
|
+
|
207
|
+
#### addExcludes
|
208
|
+
|
209
|
+
Deprecated, please use [source.exclude](https://modernjs.dev/en/configure/app/source/exclude.html) instead, both have the same functionality.
|
210
|
+
|
211
|
+
### Debugging Babel Configuration
|
212
|
+
|
213
|
+
After modifying the `babel-loader` configuration through `tools.babel`, you can view the final generated configuration in [Rsbuild debug mode](https://rsbuild.dev/guide/debug/debug-mode).
|
214
|
+
|
215
|
+
First, enable debug mode by using the `DEBUG=builder` parameter:
|
216
|
+
|
217
|
+
```bash
|
218
|
+
# Debug development mode
|
219
|
+
DEBUG=builder pnpm dev
|
220
|
+
|
221
|
+
# Debug production mode
|
222
|
+
DEBUG=builder pnpm build
|
223
|
+
```
|
224
|
+
|
225
|
+
Then open the generated `(webpack|rspack).config.web.js` file and search for the `babel-loader` keyword to see the complete `babel-loader` configuration.
|
@@ -4,6 +4,27 @@ title: bundlerChain
|
|
4
4
|
|
5
5
|
# tools.bundlerChain
|
6
6
|
|
7
|
-
|
7
|
+
- **Type:**
|
8
8
|
|
9
|
-
|
9
|
+
```ts
|
10
|
+
type BundlerChainFn = (
|
11
|
+
chain: RspackChain | webpackChain,
|
12
|
+
utils: ModifyBundlerChainUtils,
|
13
|
+
) => Promise<void> | void;
|
14
|
+
```
|
15
|
+
|
16
|
+
- **Default:** `undefined`
|
17
|
+
|
18
|
+
You can modify the webpack and 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.
|
19
|
+
|
20
|
+
:::tip What is BundlerChain
|
21
|
+
|
22
|
+
Bundler chain is a subset of webpack chain, which contains part of the webpack chain API that you can use to modify both webpack and Rspack configuration.
|
23
|
+
|
24
|
+
Configurations modified via bundler chain will work on both webpack and Rspack builds. Note that the bundler chain only supports modifying the configuration of the non-differentiated parts of webpack and Rspack. For example, modifying the devtool configuration option (webpack and Rspack have the same devtool property value type), or adding an [Rspack-compatible](https://rspack.dev/guide/compatibility/plugin) webpack plugin.
|
25
|
+
|
26
|
+
:::
|
27
|
+
|
28
|
+
> `tools.bundlerChain` is executed earlier than tools.webpackChain / tools.webpack / tools.rspack and thus will be overridden by changes in others.
|
29
|
+
|
30
|
+
For more information, please refer to [Rsbuild#tools.bundlerChain](https://rsbuild.dev/config/tools/bundler-chain).
|
@@ -1,9 +1,38 @@
|
|
1
1
|
---
|
2
2
|
title: cssExtract
|
3
|
+
configName: tools.cssExtract
|
3
4
|
---
|
4
5
|
|
5
6
|
# tools.cssExtract
|
6
7
|
|
7
|
-
|
8
|
+
- **Type:**
|
8
9
|
|
9
|
-
|
10
|
+
```ts
|
11
|
+
type CSSExtractOptions = {
|
12
|
+
pluginOptions?: Rspack.CssExtractRspackPluginOptions;
|
13
|
+
loaderOptions?: Rspack.CssExtractRspackLoaderOptions;
|
14
|
+
};
|
15
|
+
```
|
16
|
+
|
17
|
+
- **Default:**
|
18
|
+
|
19
|
+
```js
|
20
|
+
const defaultOptions = {
|
21
|
+
// The loader options
|
22
|
+
loaderOptions: {},
|
23
|
+
// The plugin options
|
24
|
+
pluginOptions: {
|
25
|
+
// The default value of cssPath is `static/css`
|
26
|
+
// while the default value of cssFilename is `[name].[contenthash:8].css`
|
27
|
+
filename: `${cssPath}/${cssFilename}`,
|
28
|
+
chunkFilename: `${cssPath}/async/${cssFilename}`,
|
29
|
+
ignoreOrder: true,
|
30
|
+
},
|
31
|
+
};
|
32
|
+
```
|
33
|
+
|
34
|
+
The config of [CssExtractRspackPlugin](https://www.rspack.dev/plugins/rspack/css-extract-rspack-plugin) / [mini-css-extract-plugin](https://github.com/webpack-contrib/mini-css-extract-plugin) can be modified through `tools.cssExtract`.
|
35
|
+
|
36
|
+
import RsbuildConig from '@site-docs-en/components/rsbuild-config-tooltip';
|
37
|
+
|
38
|
+
<RsbuildConig />
|
@@ -4,6 +4,18 @@ title: cssLoader
|
|
4
4
|
|
5
5
|
# tools.cssLoader
|
6
6
|
|
7
|
-
|
7
|
+
- **Type:** `Object | Function`
|
8
|
+
- **Default:**
|
8
9
|
|
9
|
-
|
10
|
+
```js
|
11
|
+
const defaultOptions = {
|
12
|
+
modules: rsbuildConfig.output.cssModules,
|
13
|
+
sourceMap: rsbuildConfig.output.sourceMap.css,
|
14
|
+
};
|
15
|
+
```
|
16
|
+
|
17
|
+
The config of [css-loader](https://github.com/webpack-contrib/css-loader) can be modified through `tools.cssLoader`.
|
18
|
+
|
19
|
+
import RsbuildConig from '@site-docs-en/components/rsbuild-config-tooltip';
|
20
|
+
|
21
|
+
<RsbuildConig />
|