@ohos-ports/rsbuild-core 2.2.9-beta.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/LICENSE +21 -0
- package/README.md +27 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/@rstackjs/load-config/index.d.ts +87 -0
- package/compiled/@rstackjs/load-config/license +21 -0
- package/compiled/@rstackjs/load-config/package.json +1 -0
- package/compiled/chokidar/index.d.ts +385 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect-next/index.d.ts +57 -0
- package/compiled/connect-next/license +26 -0
- package/compiled/connect-next/package.json +1 -0
- package/compiled/cors/index.d.ts +56 -0
- package/compiled/cors/license +22 -0
- package/compiled/cors/package.json +1 -0
- package/compiled/css-loader/api.js +85 -0
- package/compiled/css-loader/getUrl.js +26 -0
- package/compiled/css-loader/index.d.ts +1 -0
- package/compiled/css-loader/index.js +2 -0
- package/compiled/css-loader/license +20 -0
- package/compiled/css-loader/noSourceMaps.js +5 -0
- package/compiled/css-loader/package.json +1 -0
- package/compiled/css-loader/sourceMaps.js +16 -0
- package/compiled/html-rspack-plugin/default_index.ejs +9 -0
- package/compiled/html-rspack-plugin/htmlLoader.js +157 -0
- package/compiled/html-rspack-plugin/index.d.ts +395 -0
- package/compiled/html-rspack-plugin/index.js +2400 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +455 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/LICENSE +21 -0
- package/compiled/jiti/README.md +258 -0
- package/compiled/jiti/dist/babel.cjs +47446 -0
- package/compiled/jiti/dist/jiti.cjs +5990 -0
- package/compiled/jiti/lib/jiti-cli.mjs +19 -0
- package/compiled/jiti/lib/jiti-hooks.mjs +89 -0
- package/compiled/jiti/lib/jiti-native.mjs +76 -0
- package/compiled/jiti/lib/jiti-register.d.mts +1 -0
- package/compiled/jiti/lib/jiti-register.mjs +2 -0
- package/compiled/jiti/lib/jiti-static.mjs +19 -0
- package/compiled/jiti/lib/jiti.cjs +24 -0
- package/compiled/jiti/lib/jiti.d.cts +8 -0
- package/compiled/jiti/lib/jiti.d.mts +8 -0
- package/compiled/jiti/lib/jiti.mjs +23 -0
- package/compiled/jiti/lib/types.d.ts +420 -0
- package/compiled/jiti/package.json +146 -0
- package/compiled/postcss/index.js +1 -0
- package/compiled/postcss/lib/at-rule.d.ts +139 -0
- package/compiled/postcss/lib/comment.d.ts +67 -0
- package/compiled/postcss/lib/container.d.ts +474 -0
- package/compiled/postcss/lib/css-syntax-error.d.ts +247 -0
- package/compiled/postcss/lib/declaration.d.ts +150 -0
- package/compiled/postcss/lib/document.d.ts +68 -0
- package/compiled/postcss/lib/fromJSON.d.ts +9 -0
- package/compiled/postcss/lib/input.d.ts +226 -0
- package/compiled/postcss/lib/lazy-result.d.ts +189 -0
- package/compiled/postcss/lib/list.d.ts +60 -0
- package/compiled/postcss/lib/no-work-result.d.ts +45 -0
- package/compiled/postcss/lib/node.d.ts +555 -0
- package/compiled/postcss/lib/parse.d.ts +9 -0
- package/compiled/postcss/lib/postcss.d.ts +464 -0
- package/compiled/postcss/lib/previous-map.d.ts +80 -0
- package/compiled/postcss/lib/processor.d.ts +114 -0
- package/compiled/postcss/lib/result.d.ts +204 -0
- package/compiled/postcss/lib/root.d.ts +86 -0
- package/compiled/postcss/lib/rule.d.ts +126 -0
- package/compiled/postcss/lib/source-map-js.d.ts +4 -0
- package/compiled/postcss/lib/stringifier.d.ts +45 -0
- package/compiled/postcss/lib/stringify.d.ts +9 -0
- package/compiled/postcss/lib/warning.d.ts +146 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +721 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rslog/index.d.ts +98 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/license +22 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-chain/types/index.d.ts +515 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +52 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +370 -0
- package/compiled/style-loader/license +20 -0
- package/compiled/style-loader/package.json +1 -0
- package/compiled/style-loader/runtime/injectStylesIntoLinkTag.js +29 -0
- package/compiled/style-loader/runtime/injectStylesIntoStyleTag.js +84 -0
- package/compiled/style-loader/runtime/insertBySelector.js +34 -0
- package/compiled/style-loader/runtime/insertStyleElement.js +10 -0
- package/compiled/style-loader/runtime/isEqualLocals.js +28 -0
- package/compiled/style-loader/runtime/isOldIE.js +17 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributes.js +13 -0
- package/compiled/style-loader/runtime/setAttributesWithAttributesAndNonce.js +9 -0
- package/compiled/style-loader/runtime/setAttributesWithoutAttributes.js +10 -0
- package/compiled/style-loader/runtime/singletonStyleDomAPI.js +86 -0
- package/compiled/style-loader/runtime/styleDomAPI.js +61 -0
- package/compiled/style-loader/runtime/styleTagTransform.js +14 -0
- package/compiled/ws/index.d.ts +445 -0
- package/compiled/ws/license +21 -0
- package/compiled/ws/package.json +1 -0
- package/dist/build.d.ts +4 -0
- package/dist/c.js +10 -0
- package/dist/chokidar.js +2 -0
- package/dist/chokidar.js.LICENSE.txt +1 -0
- package/dist/cli/commands.d.ts +31 -0
- package/dist/cli/index.d.ts +7 -0
- package/dist/cli/init.d.ts +7 -0
- package/dist/client/f~0.js +22 -0
- package/dist/client/hmr.js +267 -0
- package/dist/client/overlay.js +214 -0
- package/dist/configChain.d.ts +84 -0
- package/dist/connect-next.js +2 -0
- package/dist/connect-next.js.LICENSE.txt +57 -0
- package/dist/constants.d.ts +67 -0
- package/dist/cors.js +188 -0
- package/dist/cors.js.LICENSE.txt +11 -0
- package/dist/createCompiler.d.ts +6 -0
- package/dist/createContext.d.ts +12 -0
- package/dist/createRsbuild.d.ts +4 -0
- package/dist/cssUrlLoader.mjs +34 -0
- package/dist/defaultConfig.d.ts +23 -0
- package/dist/freshImport.js +90 -0
- package/dist/helpers/cachedImport.d.ts +2 -0
- package/dist/helpers/compiler.d.ts +5 -0
- package/dist/helpers/css.d.ts +3 -0
- package/dist/helpers/exitHook.d.ts +3 -0
- package/dist/helpers/format.d.ts +4 -0
- package/dist/helpers/fs.d.ts +16 -0
- package/dist/helpers/html.d.ts +2 -0
- package/dist/helpers/index.d.ts +29 -0
- package/dist/helpers/overlayConfig.d.ts +4 -0
- package/dist/helpers/packageJson.d.ts +9 -0
- package/dist/helpers/path.d.ts +22 -0
- package/dist/helpers/restartManager.d.ts +15 -0
- package/dist/helpers/stats.d.ts +17 -0
- package/dist/helpers/url.d.ts +11 -0
- package/dist/helpers/vendors.d.ts +12 -0
- package/dist/helpers/version.d.ts +7 -0
- package/dist/hooks.d.ts +41 -0
- package/dist/http-proxy-middleware.js +14 -0
- package/dist/http-proxy-middleware.js.LICENSE.txt +34 -0
- package/dist/ignoreCssLoader.mjs +9 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.js +1 -0
- package/dist/initConfigs.d.ts +18 -0
- package/dist/initPlugins.d.ts +7 -0
- package/dist/inspectConfig.d.ts +7 -0
- package/dist/launch-editor-middleware.js +1 -0
- package/dist/loadConfig.d.ts +31 -0
- package/dist/loadEnv.d.ts +54 -0
- package/dist/loader/cssUrlLoader.d.ts +9 -0
- package/dist/loader/ignoreCssLoader.d.ts +10 -0
- package/dist/loader/transformLoader.d.ts +8 -0
- package/dist/loader/transformRawLoader.d.ts +4 -0
- package/dist/loader/workerLoader.d.ts +6 -0
- package/dist/logger.d.ts +24 -0
- package/dist/m.js +10348 -0
- package/dist/m.js.LICENSE.txt +26 -0
- package/dist/manifest-plugin.js +1 -0
- package/dist/memfs.js +1 -0
- package/dist/mergeConfig.d.ts +7 -0
- package/dist/open.js +2 -0
- package/dist/pluginHelper.d.ts +4 -0
- package/dist/pluginManager.d.ts +19 -0
- package/dist/plugins/appIcon.d.ts +2 -0
- package/dist/plugins/asset.d.ts +3 -0
- package/dist/plugins/basic.d.ts +4 -0
- package/dist/plugins/cache.d.ts +2 -0
- package/dist/plugins/cleanOutput.d.ts +2 -0
- package/dist/plugins/css.d.ts +8 -0
- package/dist/plugins/define.d.ts +2 -0
- package/dist/plugins/entry.d.ts +2 -0
- package/dist/plugins/externals.d.ts +9 -0
- package/dist/plugins/fileSize.d.ts +7 -0
- package/dist/plugins/html.d.ts +9 -0
- package/dist/plugins/inlineChunk.d.ts +6 -0
- package/dist/plugins/lazyCompilation.d.ts +2 -0
- package/dist/plugins/manifest.d.ts +2 -0
- package/dist/plugins/minimize.d.ts +10 -0
- package/dist/plugins/moduleFederation.d.ts +2 -0
- package/dist/plugins/nodeAddons.d.ts +2 -0
- package/dist/plugins/nonce.d.ts +2 -0
- package/dist/plugins/output.d.ts +2 -0
- package/dist/plugins/progress.d.ts +2 -0
- package/dist/plugins/resolve.d.ts +2 -0
- package/dist/plugins/resourceHints.d.ts +2 -0
- package/dist/plugins/rsdoctor.d.ts +2 -0
- package/dist/plugins/rspackProfile.d.ts +4 -0
- package/dist/plugins/server.d.ts +3 -0
- package/dist/plugins/sourceMap.d.ts +2 -0
- package/dist/plugins/splitChunks.d.ts +4 -0
- package/dist/plugins/sri.d.ts +2 -0
- package/dist/plugins/swc.d.ts +4 -0
- package/dist/plugins/target.d.ts +2 -0
- package/dist/plugins/wasm.d.ts +2 -0
- package/dist/plugins/worker.d.ts +2 -0
- package/dist/r.js +7 -0
- package/dist/range-parser.js +55 -0
- package/dist/range-parser.js.LICENSE.txt +6 -0
- package/dist/remapping.js +201 -0
- package/dist/restart.d.ts +15 -0
- package/dist/rslib-runtime.js +49 -0
- package/dist/rspack-plugins/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist/rspack-plugins/resource-hints/HtmlResourceHintsPlugin.d.ts +36 -0
- package/dist/rspack-plugins/resource-hints/doesChunkBelongToHtml.d.ts +27 -0
- package/dist/rspack-plugins/resource-hints/extractChunks.d.ts +22 -0
- package/dist/rspack-plugins/resource-hints/getResourceType.d.ts +21 -0
- package/dist/rspackConfig.d.ts +8 -0
- package/dist/server/ansiHTML.d.ts +3 -0
- package/dist/server/assets-middleware/getFileFromUrl.d.ts +11 -0
- package/dist/server/assets-middleware/index.d.ts +35 -0
- package/dist/server/assets-middleware/memoryFileSystem.d.ts +2 -0
- package/dist/server/assets-middleware/middleware.d.ts +7 -0
- package/dist/server/assets-middleware/parseTokenList.d.ts +1 -0
- package/dist/server/assets-middleware/setupOutputFileSystem.d.ts +3 -0
- package/dist/server/assets-middleware/setupWriteToDisk.d.ts +15 -0
- package/dist/server/browserLogs.d.ts +8 -0
- package/dist/server/buildManager.d.ts +32 -0
- package/dist/server/cliShortcuts.d.ts +19 -0
- package/dist/server/compileState.d.ts +5 -0
- package/dist/server/devMiddlewares.d.ts +18 -0
- package/dist/server/devServer.d.ts +47 -0
- package/dist/server/environment.d.ts +8 -0
- package/dist/server/gracefulShutdown.d.ts +8 -0
- package/dist/server/gzipMiddleware.d.ts +2 -0
- package/dist/server/helper.d.ts +118 -0
- package/dist/server/historyApiFallback.d.ts +10 -0
- package/dist/server/hmrFallback.d.ts +1 -0
- package/dist/server/httpServer.d.ts +7 -0
- package/dist/server/middlewares.d.ts +31 -0
- package/dist/server/open.d.ts +12 -0
- package/dist/server/overlay.d.ts +3 -0
- package/dist/server/previewServer.d.ts +4 -0
- package/dist/server/proxy.d.ts +7 -0
- package/dist/server/publicPathnames.d.ts +2 -0
- package/dist/server/runner/asModule.d.ts +2 -0
- package/dist/server/runner/basic.d.ts +25 -0
- package/dist/server/runner/cjs.d.ts +10 -0
- package/dist/server/runner/esm.d.ts +6 -0
- package/dist/server/runner/index.d.ts +6 -0
- package/dist/server/runner/type.d.ts +42 -0
- package/dist/server/serverSetup.d.ts +2 -0
- package/dist/server/socketServer.d.ts +113 -0
- package/dist/server/watchFiles.d.ts +15 -0
- package/dist/sirv.js +122 -0
- package/dist/tinyglobby.js +1 -0
- package/dist/trace-mapping.js +548 -0
- package/dist/transformLoader.mjs +36 -0
- package/dist/transformRawLoader.mjs +4 -0
- package/dist/types/config.d.ts +1796 -0
- package/dist/types/context.d.ts +89 -0
- package/dist/types/hooks.d.ts +261 -0
- package/dist/types/index.d.ts +8 -0
- package/dist/types/plugin.d.ts +479 -0
- package/dist/types/rsbuild.d.ts +241 -0
- package/dist/types/rspack.d.ts +10 -0
- package/dist/types/thirdParty.d.ts +161 -0
- package/dist/types/utils.d.ts +16 -0
- package/dist/workerLoader.mjs +94 -0
- package/dist/ws.js +2 -0
- package/package.json +107 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +422 -0
|
@@ -0,0 +1,1796 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from 'node:http';
|
|
2
|
+
import type { SecureServerSessionOptions } from 'node:http2';
|
|
3
|
+
import type { ServerOptions as HttpsServerOptions } from 'node:https';
|
|
4
|
+
import type { URL } from 'node:url';
|
|
5
|
+
import type { CopyRspackPluginOptions, DefinePluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions } from '@rspack/core';
|
|
6
|
+
import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
|
|
7
|
+
import type Cors from '../../compiled/cors/index.js';
|
|
8
|
+
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware/index.js';
|
|
9
|
+
import type { RspackChain } from '../../compiled/rspack-chain/types/index.js';
|
|
10
|
+
import type { FileDescriptor } from '../../compiled/rspack-manifest-plugin/index.js';
|
|
11
|
+
import type { HotOnConnect, HotSend, RsbuildDevServer } from '../server/devServer.js';
|
|
12
|
+
import type { RsbuildPreviewServer } from '../server/previewServer.js';
|
|
13
|
+
import type { Logger } from '../logger.js';
|
|
14
|
+
import type { EnvironmentContext, ModifyBundlerChainUtils, ModifyChainUtils, ReadonlyRoutes, WatchFileEvent } from './hooks.js';
|
|
15
|
+
import type { RsbuildPlugins } from './plugin.js';
|
|
16
|
+
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild.js';
|
|
17
|
+
import type { Rspack, RspackRule } from './rspack.js';
|
|
18
|
+
import type { Connect, CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, LoosePostCSSPlugin, PostCSSLoaderOptions, StyleLoaderOptions } from './thirdParty.js';
|
|
19
|
+
import type { ConfigChain, ConfigChainAsyncWithContext, ConfigChainWithContext, LiteralUnion, MaybePromise, OneOrMany, Optional, TwoLevelReadonly } from './utils.js';
|
|
20
|
+
export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
|
|
21
|
+
export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
|
|
22
|
+
export type ToolsPostCSSContext = {
|
|
23
|
+
addPlugins: (plugins: OneOrMany<LoosePostCSSPlugin>, options?: {
|
|
24
|
+
/**
|
|
25
|
+
* Controls where the plugin is placed relative to the existing PostCSS plugins.
|
|
26
|
+
* - `pre`: Insert the plugin before all existing plugins.
|
|
27
|
+
* - `post`: Insert the plugin after all existing plugins.
|
|
28
|
+
* @default `post`
|
|
29
|
+
*/ order?: 'pre' | 'post';
|
|
30
|
+
}) => void;
|
|
31
|
+
};
|
|
32
|
+
export type ToolsPostCSSLoaderConfig = ConfigChainWithContext<PostCSSLoaderOptions, ToolsPostCSSContext>;
|
|
33
|
+
export type ToolsCSSLoaderConfig = ConfigChain<CSSLoaderOptions>;
|
|
34
|
+
export type ToolsStyleLoaderConfig = ConfigChain<StyleLoaderOptions>;
|
|
35
|
+
export type ToolsHtmlPluginConfig = ConfigChainWithContext<HtmlRspackPlugin.Options, {
|
|
36
|
+
entryName: string;
|
|
37
|
+
entryValue: (string | string[] | Rspack.EntryDescription)[];
|
|
38
|
+
}>;
|
|
39
|
+
// equivalent to import('rspack-merge').merge
|
|
40
|
+
export type RspackMerge = (firstConfiguration: Rspack.Configuration | Rspack.Configuration[], ...configurations: Rspack.Configuration[]) => Rspack.Configuration;
|
|
41
|
+
export type ModifyRspackConfigUtils = ModifyChainUtils & {
|
|
42
|
+
addRules: (rules: OneOrMany<RspackRule>) => void;
|
|
43
|
+
appendRules: (rules: OneOrMany<RspackRule>) => void;
|
|
44
|
+
prependPlugins: (plugins: OneOrMany<Rspack.Plugin>) => void;
|
|
45
|
+
appendPlugins: (plugins: OneOrMany<Rspack.Plugin>) => void;
|
|
46
|
+
removePlugin: (pluginName: string) => void;
|
|
47
|
+
mergeConfig: RspackMerge;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* Narrow the type of Rspack.Configuration to make it easier
|
|
51
|
+
* to use `tools.rspack` function. These properties are set
|
|
52
|
+
* by Rsbuild by default so they are non-nullable.
|
|
53
|
+
*
|
|
54
|
+
* - With `Rspack.Configuration`, the `plugins` property is nullable:
|
|
55
|
+
*
|
|
56
|
+
* ```js
|
|
57
|
+
* tools: {
|
|
58
|
+
* rspack(config) {
|
|
59
|
+
* if (!config.plugins) {
|
|
60
|
+
* config.plugins = [];
|
|
61
|
+
* }
|
|
62
|
+
* config.plugins.push(new SomePlugin());
|
|
63
|
+
* }
|
|
64
|
+
* }
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* - With `NarrowedRspackConfig`, the `plugins` property is non-nullable:
|
|
68
|
+
*
|
|
69
|
+
* ```js
|
|
70
|
+
* tools: {
|
|
71
|
+
* rspack(config) {
|
|
72
|
+
* config.plugins.push(new SomePlugin());
|
|
73
|
+
* }
|
|
74
|
+
* }
|
|
75
|
+
* ```
|
|
76
|
+
*/ export type NarrowedRspackConfig = Omit<Rspack.Configuration, 'plugins' | 'module' | 'resolve' | 'output'> & {
|
|
77
|
+
/**
|
|
78
|
+
* Plugins to use during compilation.
|
|
79
|
+
*/ plugins: Rspack.Plugin[];
|
|
80
|
+
/**
|
|
81
|
+
* Options for module configuration.
|
|
82
|
+
*/ module: NonNullable<Rspack.Configuration['module']>;
|
|
83
|
+
/**
|
|
84
|
+
* Options for resolving modules.
|
|
85
|
+
*/ resolve: NonNullable<Rspack.Configuration['resolve']>;
|
|
86
|
+
/**
|
|
87
|
+
* Configuration for the output of the compilation.
|
|
88
|
+
*/ output: NonNullable<Rspack.Configuration['output']>;
|
|
89
|
+
};
|
|
90
|
+
export type ToolsRspackConfig = OneOrMany<Rspack.Configuration | ((config: NarrowedRspackConfig, ctx: ModifyRspackConfigUtils) => MaybePromise<Rspack.Configuration | void>)>;
|
|
91
|
+
export interface ToolsConfig {
|
|
92
|
+
/**
|
|
93
|
+
* Configure bundler config base on [rspack-chain](https://github.com/rstackjs/rspack-chain)
|
|
94
|
+
*/ bundlerChain?: ToolsBundlerChainConfig;
|
|
95
|
+
/**
|
|
96
|
+
* Modify the options of [css-loader](https://github.com/webpack/css-loader).
|
|
97
|
+
*/ cssLoader?: ToolsCSSLoaderConfig;
|
|
98
|
+
/**
|
|
99
|
+
* Modify the options of [postcss-loader](https://github.com/webpack/postcss-loader).
|
|
100
|
+
*/ postcss?: ToolsPostCSSLoaderConfig;
|
|
101
|
+
/**
|
|
102
|
+
* Modify the options of [style-loader](https://github.com/webpack/style-loader).
|
|
103
|
+
*/ styleLoader?: ToolsStyleLoaderConfig;
|
|
104
|
+
/**
|
|
105
|
+
* Configure the html-rspack-plugin.
|
|
106
|
+
*/ htmlPlugin?: boolean | ToolsHtmlPluginConfig;
|
|
107
|
+
/**
|
|
108
|
+
* Configure the `builtin:swc-loader` of Rspack.
|
|
109
|
+
*/ swc?: ToolsSwcConfig;
|
|
110
|
+
/**
|
|
111
|
+
* Configure the `builtin:lightningcss-loader` of Rspack.
|
|
112
|
+
*/ lightningcssLoader?: boolean | ConfigChain<Rspack.LightningcssLoaderOptions>;
|
|
113
|
+
/**
|
|
114
|
+
* Modify the options of [CssExtractRspackPlugin](https://rspack.rs/plugins/css-extract-rspack-plugin).
|
|
115
|
+
*/ cssExtract?: CSSExtractOptions;
|
|
116
|
+
/**
|
|
117
|
+
* Configure Rspack.
|
|
118
|
+
*/ rspack?: ToolsRspackConfig;
|
|
119
|
+
}
|
|
120
|
+
export type NormalizedToolsConfig = ToolsConfig & {
|
|
121
|
+
cssExtract: Required<CSSExtractOptions>;
|
|
122
|
+
};
|
|
123
|
+
export type Alias = Record<string, string | false | (string | false)[]>;
|
|
124
|
+
export type AliasStrategy = 'prefer-tsconfig' | 'prefer-alias';
|
|
125
|
+
export type Decorators = {
|
|
126
|
+
/**
|
|
127
|
+
* Specify the version of decorators to use.
|
|
128
|
+
* @default '2023-11'
|
|
129
|
+
*/ version?: 'legacy'// stage 1
|
|
130
|
+
| '2022-03'// stage 3
|
|
131
|
+
| '2023-11';
|
|
132
|
+
};
|
|
133
|
+
export interface SourceConfig {
|
|
134
|
+
/**
|
|
135
|
+
* Include additional files that should be treated as static assets.
|
|
136
|
+
* @default undefined
|
|
137
|
+
*/ assetsInclude?: Rspack.RuleSetCondition;
|
|
138
|
+
/**
|
|
139
|
+
* Specify additional JavaScript files that need to be compiled by SWC.
|
|
140
|
+
* Through the `source.include` config, you can specify directories or modules
|
|
141
|
+
* that need to be compiled by Rsbuild. The usage of `source.include` is
|
|
142
|
+
* consistent with [rules[].include](https://rspack.rs/config/module-rules#rulesinclude)
|
|
143
|
+
* in Rspack, which supports passing in strings or regular expressions to match
|
|
144
|
+
* the module path.
|
|
145
|
+
* @default
|
|
146
|
+
* [
|
|
147
|
+
* { and: [rootPath, { not: /[\\/]node_modules[\\/]/ }], },
|
|
148
|
+
* /\.(?:ts|tsx|jsx|mts|cts)$/,
|
|
149
|
+
* ];
|
|
150
|
+
*/ include?: RuleSetCondition[];
|
|
151
|
+
/**
|
|
152
|
+
* Set the entry modules for building.
|
|
153
|
+
*
|
|
154
|
+
* The value of `source.entry` is an object, the key is the entry name, and the
|
|
155
|
+
* value is the path of the entry module or a description object.
|
|
156
|
+
*
|
|
157
|
+
* If the value is a path, it can be an absolute path or a relative path, the
|
|
158
|
+
* relative path will be resolved based on `root`.
|
|
159
|
+
*
|
|
160
|
+
* @default
|
|
161
|
+
* {
|
|
162
|
+
* // Rsbuild also supports other suffixes by default, such as ts,
|
|
163
|
+
* // tsx, jsx, mts, cts, mjs, cjs
|
|
164
|
+
* index: './src/index.js',
|
|
165
|
+
* }
|
|
166
|
+
*/ entry?: RsbuildEntry;
|
|
167
|
+
/**
|
|
168
|
+
* Exclude JavaScript or TypeScript files that do not need to be compiled by SWC.
|
|
169
|
+
*/ exclude?: RuleSetCondition[];
|
|
170
|
+
/**
|
|
171
|
+
* Add a script before the entry file of each page.
|
|
172
|
+
* This script will be executed before the page code.
|
|
173
|
+
* It can be used to execute global logics, such as polyfill injection.
|
|
174
|
+
*/ preEntry?: string | string[];
|
|
175
|
+
/**
|
|
176
|
+
* Replaces variables in your code with other values or expressions at compile time.
|
|
177
|
+
* This is useful for enabling different behavior between development and production builds.
|
|
178
|
+
*/ define?: DefinePluginOptions;
|
|
179
|
+
/**
|
|
180
|
+
* Configuring decorators syntax.
|
|
181
|
+
*/ decorators?: Decorators;
|
|
182
|
+
/**
|
|
183
|
+
* Used to import the code and style of the component library on demand.
|
|
184
|
+
*/ transformImport?: TransformImportFn | (TransformImport | TransformImportFn)[];
|
|
185
|
+
/**
|
|
186
|
+
* Configure a custom tsconfig.json file path to use, can be a relative or absolute path.
|
|
187
|
+
* @default 'tsconfig.json'
|
|
188
|
+
*/ tsconfigPath?: string;
|
|
189
|
+
}
|
|
190
|
+
export type TransformImport = {
|
|
191
|
+
libraryName: string;
|
|
192
|
+
libraryDirectory?: string;
|
|
193
|
+
customName?: string;
|
|
194
|
+
customStyleName?: string;
|
|
195
|
+
style?: string | boolean;
|
|
196
|
+
styleLibraryDirectory?: string;
|
|
197
|
+
camelToDashComponentName?: boolean;
|
|
198
|
+
transformToDefaultImport?: boolean;
|
|
199
|
+
ignoreEsComponent?: string[];
|
|
200
|
+
ignoreStyleComponent?: string[];
|
|
201
|
+
};
|
|
202
|
+
type TransformImportFn = (imports: TransformImport[]) => TransformImport[] | void;
|
|
203
|
+
export interface NormalizedSourceConfig extends SourceConfig {
|
|
204
|
+
define: DefinePluginOptions;
|
|
205
|
+
preEntry: string[];
|
|
206
|
+
decorators: Required<Decorators>;
|
|
207
|
+
}
|
|
208
|
+
export type HtmlFallback = false | 'index';
|
|
209
|
+
export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => MaybePromise<string | undefined | null | boolean>;
|
|
210
|
+
export type { ProxyFilter };
|
|
211
|
+
export type ProxyOptions = HttpProxyOptions & {
|
|
212
|
+
/**
|
|
213
|
+
* Use the `bypass` function to skip the proxy.
|
|
214
|
+
* Inside the function, you have access to the request, response, and proxy options.
|
|
215
|
+
* - Return `null` or `undefined` to continue processing the request with proxy.
|
|
216
|
+
* - Return `true` to skip the proxy and continue processing the request.
|
|
217
|
+
* - Return `false` to produce a 404 error for the request.
|
|
218
|
+
* - Return a specific path to replace the original request path.
|
|
219
|
+
* - Return a Promise to handle the request asynchronously.
|
|
220
|
+
*/ bypass?: ProxyBypass;
|
|
221
|
+
};
|
|
222
|
+
export type ProxyConfig = Record<string, string | ProxyOptions> | ProxyOptions[];
|
|
223
|
+
export type HistoryApiFallbackContext = {
|
|
224
|
+
match: RegExpMatchArray;
|
|
225
|
+
parsedUrl: URL;
|
|
226
|
+
request: IncomingMessage;
|
|
227
|
+
};
|
|
228
|
+
export type HistoryApiFallbackTo = string | ((context: HistoryApiFallbackContext) => string);
|
|
229
|
+
export type HistoryApiFallbackOptions = {
|
|
230
|
+
/**
|
|
231
|
+
* Specifies the default HTML file to return when the History API fallback is enabled.
|
|
232
|
+
* For example, if you set `historyApiFallback.index` to `main.html`, the server will
|
|
233
|
+
* automatically serve `main.html` as the fallback page when users access any unmatched
|
|
234
|
+
* routes.
|
|
235
|
+
* @default 'index.html'
|
|
236
|
+
*/ index?: string;
|
|
237
|
+
/**
|
|
238
|
+
* Override the default `Accepts:` headers that are queried when matching HTML content
|
|
239
|
+
* requests.
|
|
240
|
+
* @default ['text/html', '*\/*']
|
|
241
|
+
*/ htmlAcceptHeaders?: string[];
|
|
242
|
+
/**
|
|
243
|
+
* By default, requests containing a dot (`.`) in the path are treated as direct file
|
|
244
|
+
* requests and are not redirected. Setting `disableDotRule` to `true` will disable this
|
|
245
|
+
* behavior and allow such requests to be redirected as well.
|
|
246
|
+
* @default false
|
|
247
|
+
*/ disableDotRule?: boolean;
|
|
248
|
+
/**
|
|
249
|
+
* `rewrites` lets you customize how request paths are mapped to HTML files when
|
|
250
|
+
* a History API fallback occurs. These rules only apply when no static asset matches
|
|
251
|
+
* the request, meaning it has entered the fallback stage. Each rule is evaluated in
|
|
252
|
+
* order until a match is found and executed.
|
|
253
|
+
*/ rewrites?: {
|
|
254
|
+
from: RegExp;
|
|
255
|
+
to: HistoryApiFallbackTo;
|
|
256
|
+
}[];
|
|
257
|
+
};
|
|
258
|
+
export type PrintUrlsParams = {
|
|
259
|
+
urls: string[];
|
|
260
|
+
port: number;
|
|
261
|
+
routes: ReadonlyRoutes;
|
|
262
|
+
protocol: string;
|
|
263
|
+
};
|
|
264
|
+
export type PrintUrlsOptions = {
|
|
265
|
+
/**
|
|
266
|
+
* The maximum number of entry URLs to print.
|
|
267
|
+
* Set to `0` to print only the server URL without entry routes.
|
|
268
|
+
* @default 10
|
|
269
|
+
*/ maxRoutes?: number;
|
|
270
|
+
};
|
|
271
|
+
export type PrintUrls = boolean | PrintUrlsOptions | ((params: PrintUrlsParams) => (string | {
|
|
272
|
+
url: string;
|
|
273
|
+
label?: string;
|
|
274
|
+
})[] | void);
|
|
275
|
+
export type PublicDirOptions = {
|
|
276
|
+
/**
|
|
277
|
+
* The name of the public directory, can be set as a relative path or an absolute path.
|
|
278
|
+
* @default 'public'
|
|
279
|
+
*/ name?: string;
|
|
280
|
+
/**
|
|
281
|
+
* Whether to copy files from the public directory to the dist directory on production build.
|
|
282
|
+
* - `true`: copy files
|
|
283
|
+
* - `false`: do not copy files
|
|
284
|
+
* - `'auto'`: if `output.target` is not `'node'`, copy files, otherwise do not copy
|
|
285
|
+
* @default 'auto'
|
|
286
|
+
*/ copyOnBuild?: boolean | 'auto';
|
|
287
|
+
/**
|
|
288
|
+
* whether to watch the public directory and reload the page when the files change
|
|
289
|
+
* @default false
|
|
290
|
+
*/ watch?: boolean;
|
|
291
|
+
/**
|
|
292
|
+
* Glob patterns for files or directories to ignore when copying the public directory
|
|
293
|
+
* during production builds.
|
|
294
|
+
* @default []
|
|
295
|
+
*/ ignore?: string[];
|
|
296
|
+
};
|
|
297
|
+
export type PublicDir = false | PublicDirOptions | PublicDirOptions[];
|
|
298
|
+
/**
|
|
299
|
+
* The options for `server.compress`.
|
|
300
|
+
*/ export type CompressOptions = {
|
|
301
|
+
/**
|
|
302
|
+
* A function that determines whether a response should be compressed.
|
|
303
|
+
* @param req - The incoming HTTP request
|
|
304
|
+
* @param res - The outgoing HTTP response
|
|
305
|
+
* @returns `true` to compress the response, `false` to skip compression
|
|
306
|
+
*/ filter?: (req: IncomingMessage, res: ServerResponse) => boolean;
|
|
307
|
+
/**
|
|
308
|
+
* The level of zlib compression to apply to responses.
|
|
309
|
+
* A higher level will result in better compression, but will take longer to complete.
|
|
310
|
+
* A lower level will result in less compression, but will be much faster.
|
|
311
|
+
* This is an integer in the range of 0 (no compression) to 9 (maximum compression).
|
|
312
|
+
* @default
|
|
313
|
+
* - 1 (fastest) for dev server (also known as `zlib.constants.Z_BEST_SPEED`)
|
|
314
|
+
* - 6 for preview server (also known as `zlib.constants.Z_DEFAULT_COMPRESSION`)
|
|
315
|
+
*/ level?: number;
|
|
316
|
+
};
|
|
317
|
+
export interface ServerConfig {
|
|
318
|
+
/**
|
|
319
|
+
* Configure the base path of the server.
|
|
320
|
+
* @default '/'
|
|
321
|
+
*/ base?: string;
|
|
322
|
+
/**
|
|
323
|
+
* Whether to enable gzip compression for served static assets.
|
|
324
|
+
* Pass an object to customize the compression behavior.
|
|
325
|
+
* @default true
|
|
326
|
+
*/ compress?: boolean | CompressOptions;
|
|
327
|
+
/**
|
|
328
|
+
* Serving static files from the directory
|
|
329
|
+
* @default { name: 'public', copyOnBuild: 'auto', watch: false }
|
|
330
|
+
*/ publicDir?: PublicDir;
|
|
331
|
+
/**
|
|
332
|
+
* Specify a port number for Rsbuild server to listen.
|
|
333
|
+
* @default 3000
|
|
334
|
+
*/ port?: number;
|
|
335
|
+
/**
|
|
336
|
+
* Configure HTTPS options to enable HTTPS server.
|
|
337
|
+
* When enabled, HTTP server will be disabled.
|
|
338
|
+
* @default undefined
|
|
339
|
+
*/ https?: HttpsServerOptions | SecureServerSessionOptions;
|
|
340
|
+
/**
|
|
341
|
+
* Specify the host that the Rsbuild server listens to.
|
|
342
|
+
* - `string`: specify a hostname or IP address to listen on.
|
|
343
|
+
* - `true`: equals to `0.0.0.0`, listen on all interfaces.
|
|
344
|
+
* - `false`: equals to `localhost`
|
|
345
|
+
* @default 'localhost'
|
|
346
|
+
*/ host?: string | boolean;
|
|
347
|
+
/**
|
|
348
|
+
* Adds headers to all responses.
|
|
349
|
+
*/ headers?: Record<string, string | string[]>;
|
|
350
|
+
/**
|
|
351
|
+
* Whether to enable HTML fallback.
|
|
352
|
+
* @default 'index'
|
|
353
|
+
*/ htmlFallback?: HtmlFallback;
|
|
354
|
+
/**
|
|
355
|
+
* Used to support routing based on the history API.
|
|
356
|
+
* When a user visits a path that does not exist, it will automatically
|
|
357
|
+
* return a specified HTML file to avoid a 404 error.
|
|
358
|
+
* @default false
|
|
359
|
+
*/ historyApiFallback?: boolean | HistoryApiFallbackOptions;
|
|
360
|
+
/**
|
|
361
|
+
* Set the page URL to open when the server starts.
|
|
362
|
+
* @default false
|
|
363
|
+
*/ open?: boolean | string | string[] | {
|
|
364
|
+
target?: string | string[];
|
|
365
|
+
before?: () => Promise<void> | void;
|
|
366
|
+
};
|
|
367
|
+
/**
|
|
368
|
+
* Configure CORS for the dev server or preview server.
|
|
369
|
+
* - object: enable CORS with the specified options.
|
|
370
|
+
* - true: enable CORS with default options (allow all origins, not recommended).
|
|
371
|
+
* - false: disable CORS.
|
|
372
|
+
* @default
|
|
373
|
+
* ```js
|
|
374
|
+
* { origin: defaultAllowedOrigins }
|
|
375
|
+
* ```
|
|
376
|
+
* where `defaultAllowedOrigins` includes:
|
|
377
|
+
* - `localhost`
|
|
378
|
+
* - `127.0.0.1`
|
|
379
|
+
* - `[::1]`
|
|
380
|
+
*
|
|
381
|
+
* @link https://github.com/expressjs/cors
|
|
382
|
+
*/ cors?: boolean | Cors.CorsOptions;
|
|
383
|
+
/**
|
|
384
|
+
* Configure proxy rules for the dev server or preview server to proxy requests to
|
|
385
|
+
* the specified service.
|
|
386
|
+
*/ proxy?: ProxyConfig;
|
|
387
|
+
/**
|
|
388
|
+
* Whether to throw an error when the port is occupied.
|
|
389
|
+
* @default false
|
|
390
|
+
*/ strictPort?: boolean;
|
|
391
|
+
/**
|
|
392
|
+
* Controls whether and how server URLs are printed when the server starts.
|
|
393
|
+
* @default true
|
|
394
|
+
*/ printUrls?: PrintUrls;
|
|
395
|
+
/**
|
|
396
|
+
* Whether to create Rsbuild's server in middleware mode, which is useful for
|
|
397
|
+
* integrating with other servers.
|
|
398
|
+
* @default false
|
|
399
|
+
*/ middlewareMode?: boolean;
|
|
400
|
+
/**
|
|
401
|
+
* Run setup logic when the Rsbuild dev server or preview server starts,
|
|
402
|
+
* such as registering custom middleware or running pre-start tasks.
|
|
403
|
+
*
|
|
404
|
+
* When `server.setup` is called, Rsbuild built-in middlewares are not registered yet,
|
|
405
|
+
* so middlewares you add run earlier than built-ins.
|
|
406
|
+
*
|
|
407
|
+
* `server.setup` can return a callback function. After built-in middlewares are registered,
|
|
408
|
+
* Rsbuild will execute that callback. Middlewares registered in the callback run later than built-ins.
|
|
409
|
+
*
|
|
410
|
+
* @default undefined
|
|
411
|
+
*/ setup?: ServerSetupFn | ServerSetupFn[];
|
|
412
|
+
}
|
|
413
|
+
export type NormalizedServerConfig = {
|
|
414
|
+
host: string;
|
|
415
|
+
publicDir: Required<PublicDirOptions>[];
|
|
416
|
+
} & Omit<Optional<Required<ServerConfig>, 'headers' | 'https' | 'historyApiFallback' | 'proxy' | 'setup'>, 'host' | 'publicDir'>;
|
|
417
|
+
export type ServerSetupContext = {
|
|
418
|
+
/**
|
|
419
|
+
* Environment contexts of all environments.
|
|
420
|
+
*/ environments: Record<string, EnvironmentContext>;
|
|
421
|
+
} & ({
|
|
422
|
+
/**
|
|
423
|
+
* Action type of current server.
|
|
424
|
+
*/ action: 'dev';
|
|
425
|
+
/**
|
|
426
|
+
* Dev server instance, only available in dev mode.
|
|
427
|
+
*/ server: RsbuildDevServer;
|
|
428
|
+
} | {
|
|
429
|
+
/**
|
|
430
|
+
* Action type of current server.
|
|
431
|
+
*/ action: 'preview';
|
|
432
|
+
/**
|
|
433
|
+
* Preview server instance, only available in preview mode.
|
|
434
|
+
*/ server: RsbuildPreviewServer;
|
|
435
|
+
});
|
|
436
|
+
/**
|
|
437
|
+
* Server setup function.
|
|
438
|
+
* Return a callback to run after built-in middlewares are registered.
|
|
439
|
+
*/ export type ServerSetupFn = (context: ServerSetupContext) => MaybePromise<(() => MaybePromise<void>) | void>;
|
|
440
|
+
export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
|
441
|
+
export type SriOptions = {
|
|
442
|
+
/**
|
|
443
|
+
* Specifies the algorithm used to compute the integrity hash.
|
|
444
|
+
* @default 'sha384'
|
|
445
|
+
*/ algorithm?: SriAlgorithm | SriAlgorithm[];
|
|
446
|
+
/**
|
|
447
|
+
* Whether to enable SRI.
|
|
448
|
+
* `'auto'` means it's enabled in production mode and disabled in development mode.
|
|
449
|
+
* @default false
|
|
450
|
+
*/ enable?: boolean | 'auto';
|
|
451
|
+
};
|
|
452
|
+
export interface SecurityConfig {
|
|
453
|
+
/**
|
|
454
|
+
* Adding a `nonce` attribute to the scripts resources introduced for HTML. This allows
|
|
455
|
+
* the browser to determine whether the script can be executed when it parses inline
|
|
456
|
+
* scripts with matching nonce values.
|
|
457
|
+
*/ nonce?: string;
|
|
458
|
+
/**
|
|
459
|
+
* Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML
|
|
460
|
+
* allows the browser to verify the integrity of the introduced resource, thus preventing
|
|
461
|
+
* tampering with the downloaded resource.
|
|
462
|
+
*/ sri?: SriOptions;
|
|
463
|
+
}
|
|
464
|
+
export type NormalizedSecurityConfig = Required<SecurityConfig>;
|
|
465
|
+
export type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group';
|
|
466
|
+
export type BuildCacheOptions = {
|
|
467
|
+
/**
|
|
468
|
+
* The output directory of the cache files.
|
|
469
|
+
* @default 'node_modules/.cache'
|
|
470
|
+
*/ cacheDirectory?: string;
|
|
471
|
+
/**
|
|
472
|
+
* Add additional cache digests, the previous build cache will be invalidated
|
|
473
|
+
* when any value in the array changes.
|
|
474
|
+
* @default undefined
|
|
475
|
+
*/ cacheDigest?: (string | undefined)[];
|
|
476
|
+
/**
|
|
477
|
+
* An array of files containing build dependencies.
|
|
478
|
+
* Rspack will use the hash of each of these files to invalidate the persistent cache.
|
|
479
|
+
*/ buildDependencies?: string[];
|
|
480
|
+
};
|
|
481
|
+
export type PrintFileSizeAsset = {
|
|
482
|
+
/**
|
|
483
|
+
* The name of the asset.
|
|
484
|
+
* @example 'index.html', 'static/js/index.[hash].js'
|
|
485
|
+
*/ name: string;
|
|
486
|
+
/**
|
|
487
|
+
* The size of the asset in bytes.
|
|
488
|
+
*/ size: number;
|
|
489
|
+
};
|
|
490
|
+
export type PrintFileSizeOptions = {
|
|
491
|
+
/**
|
|
492
|
+
* Whether to print the total size of all static assets, or a function to generate custom total output.
|
|
493
|
+
* @default true
|
|
494
|
+
*/ total?: boolean | ((params: {
|
|
495
|
+
environmentName: string;
|
|
496
|
+
distPath: string;
|
|
497
|
+
assets: PrintFileSizeAsset[];
|
|
498
|
+
totalSize: number;
|
|
499
|
+
totalGzipSize: number;
|
|
500
|
+
totalBrotliSize?: number;
|
|
501
|
+
}) => string);
|
|
502
|
+
/**
|
|
503
|
+
* Whether to print the size of each static asset.
|
|
504
|
+
* @default true
|
|
505
|
+
*/ detail?: boolean;
|
|
506
|
+
/**
|
|
507
|
+
* Whether to print the compressed size of each static asset.
|
|
508
|
+
* Set to `true` to use gzip, or specify `type` to select gzip or Brotli.
|
|
509
|
+
* Disabling this option saves compression computation time for large projects.
|
|
510
|
+
* @default true
|
|
511
|
+
*/ compressed?: boolean | {
|
|
512
|
+
/**
|
|
513
|
+
* The compression algorithm used to calculate file sizes.
|
|
514
|
+
* @default 'gzip'
|
|
515
|
+
*/ type?: 'gzip' | 'brotli';
|
|
516
|
+
/**
|
|
517
|
+
* The compression level: an integer from 0 to 9 for gzip, or 0 to 11 for Brotli.
|
|
518
|
+
* Higher levels generally produce smaller sizes but take longer to calculate.
|
|
519
|
+
* @default 6
|
|
520
|
+
*/ level?: number;
|
|
521
|
+
};
|
|
522
|
+
/**
|
|
523
|
+
* A filter function to determine which static assets to print.
|
|
524
|
+
* If returned `false`, the static asset will be excluded and not included in the
|
|
525
|
+
* total size or detailed size.
|
|
526
|
+
* @default undefined
|
|
527
|
+
*/ include?: (asset: PrintFileSizeAsset) => boolean;
|
|
528
|
+
/**
|
|
529
|
+
* A filter function to exclude static assets from the total size or detailed size.
|
|
530
|
+
* If both `include` and `exclude` are set, `exclude` will take precedence.
|
|
531
|
+
* @default (asset) => /\.(?:map|LICENSE\.txt|d\.(?:ts|mts|cts))$/.test(asset.name)
|
|
532
|
+
*/ exclude?: (asset: PrintFileSizeAsset) => boolean;
|
|
533
|
+
/**
|
|
534
|
+
* Controls whether file size differences are displayed relative to the previous build.
|
|
535
|
+
* When this option is enabled, Rsbuild records a snapshot of all output file sizes after
|
|
536
|
+
* each build. On subsequent builds, Rsbuild compares the current sizes against the previous
|
|
537
|
+
* snapshot and shows the change inline in parentheses.
|
|
538
|
+
* @default false
|
|
539
|
+
*/ diff?: boolean;
|
|
540
|
+
};
|
|
541
|
+
export interface PreconnectOption {
|
|
542
|
+
/**
|
|
543
|
+
* The URL of the resource to preconnect to.
|
|
544
|
+
*/ href: string;
|
|
545
|
+
/**
|
|
546
|
+
* Whether to add `crossorigin` attribute to the `<link>` element.
|
|
547
|
+
*/ crossorigin?: boolean;
|
|
548
|
+
}
|
|
549
|
+
export type Preconnect = (string | PreconnectOption)[];
|
|
550
|
+
export type DnsPrefetch = string[];
|
|
551
|
+
export type ResourceHintsIncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
|
|
552
|
+
export type ResourceHintsFilterFn = (filename: string) => boolean;
|
|
553
|
+
export type ResourceHintsFilter = OneOrMany<string | RegExp | ResourceHintsFilterFn>;
|
|
554
|
+
export interface ResourceHintsOptions {
|
|
555
|
+
/**
|
|
556
|
+
* Specifies which types of resources will be included.
|
|
557
|
+
* - `async-chunks`: Includes all async resources on the current page, such as async JS
|
|
558
|
+
* chunks, and its associated CSS, images, and fonts.
|
|
559
|
+
* - `initial`: Includes all non-async resources on the current page.
|
|
560
|
+
* - `all-chunks`: Includes all async and non-async resources on the current page.
|
|
561
|
+
* - `all-assets`: Includes all resources from all pages.
|
|
562
|
+
* @default 'async-chunks'
|
|
563
|
+
*/ type?: ResourceHintsIncludeType;
|
|
564
|
+
/**
|
|
565
|
+
* An extra filter to determine which resources to include.
|
|
566
|
+
*/ include?: ResourceHintsFilter;
|
|
567
|
+
/**
|
|
568
|
+
* An extra filter to determine which resources to exclude.
|
|
569
|
+
*
|
|
570
|
+
* @default /\.(?:webmanifest|pdf|txt)$/i
|
|
571
|
+
*/ exclude?: ResourceHintsFilter;
|
|
572
|
+
/**
|
|
573
|
+
* Whether to dedupe script resources that already exist in the current HTML content.
|
|
574
|
+
* By default, if a resource has been added to the current HTML via a script tag, it will
|
|
575
|
+
* not be preloaded additionally.
|
|
576
|
+
* @default true
|
|
577
|
+
*/ dedupe?: boolean;
|
|
578
|
+
}
|
|
579
|
+
export type PreloadOptions = ResourceHintsOptions;
|
|
580
|
+
export type PrefetchOptions = Omit<ResourceHintsOptions, 'dedupe'>;
|
|
581
|
+
export interface PerformanceConfig {
|
|
582
|
+
/**
|
|
583
|
+
* Whether to remove `console.[methodName]` in production build.
|
|
584
|
+
* @default false
|
|
585
|
+
*/ removeConsole?: boolean | ConsoleType[];
|
|
586
|
+
/**
|
|
587
|
+
* To enable or configure persistent build cache.
|
|
588
|
+
* @default false
|
|
589
|
+
*/ buildCache?: BuildCacheOptions | boolean;
|
|
590
|
+
/**
|
|
591
|
+
* Whether to print the file sizes after production build.
|
|
592
|
+
* @default true
|
|
593
|
+
*/ printFileSize?: PrintFileSizeOptions | boolean;
|
|
594
|
+
/**
|
|
595
|
+
* Configure the chunk splitting strategy.
|
|
596
|
+
* @deprecated Use `splitChunks` instead.
|
|
597
|
+
*/ chunkSplit?: ChunkSplit;
|
|
598
|
+
/**
|
|
599
|
+
* Used to control resource `Preconnect`.
|
|
600
|
+
*
|
|
601
|
+
* Specifies that the user agent should preemptively connect to the target resource's origin.
|
|
602
|
+
*/ preconnect?: Preconnect;
|
|
603
|
+
/**
|
|
604
|
+
* Used to control resource `DnsPrefetch`.
|
|
605
|
+
*
|
|
606
|
+
* Specifies that the user agent should preemptively perform DNS resolution for the target
|
|
607
|
+
* resource's origin.
|
|
608
|
+
*/ dnsPrefetch?: DnsPrefetch;
|
|
609
|
+
/**
|
|
610
|
+
* Inject the `<link rel="preload">` tags for the static assets generated by Rsbuild.
|
|
611
|
+
*
|
|
612
|
+
* `performance.preload` can be set to an object or an array of objects to specify the options.
|
|
613
|
+
*
|
|
614
|
+
* When `performance.preload` is set to `true`, Rsbuild will use the following default
|
|
615
|
+
* options to preload resources. This means preloading all async resources on the current
|
|
616
|
+
* page, including async JS and its associated CSS, image, and font resources.
|
|
617
|
+
*
|
|
618
|
+
* ```js
|
|
619
|
+
* const defaultOptions = {
|
|
620
|
+
* type: 'async-chunks',
|
|
621
|
+
* };
|
|
622
|
+
* ```
|
|
623
|
+
* @default undefined
|
|
624
|
+
*/ preload?: true | OneOrMany<PreloadOptions>;
|
|
625
|
+
/**
|
|
626
|
+
* Inject the `<link rel="prefetch">` tags for the static assets generated by Rsbuild.
|
|
627
|
+
*
|
|
628
|
+
* `performance.prefetch` can be set to an object or an array of objects to specify the options.
|
|
629
|
+
*
|
|
630
|
+
* When `performance.prefetch` is set to `true`, Rsbuild will use the following default
|
|
631
|
+
* options to prefetch resources. This means prefetching all async resources on the current
|
|
632
|
+
* page, including async JS and its associated CSS, image, and font resources.
|
|
633
|
+
*
|
|
634
|
+
* ```js
|
|
635
|
+
* const defaultOptions = {
|
|
636
|
+
* type: 'async-chunks',
|
|
637
|
+
* };
|
|
638
|
+
* ```
|
|
639
|
+
* @default undefined
|
|
640
|
+
*/ prefetch?: true | OneOrMany<PrefetchOptions>;
|
|
641
|
+
}
|
|
642
|
+
export interface NormalizedPerformanceConfig extends PerformanceConfig {
|
|
643
|
+
printFileSize: PrintFileSizeOptions | boolean;
|
|
644
|
+
}
|
|
645
|
+
export type SplitChunks = Rspack.OptimizationSplitChunksOptions | false;
|
|
646
|
+
/**
|
|
647
|
+
* Split chunks preset rules.
|
|
648
|
+
* - `default`: splits polyfills when enabled and applies extra groups when using
|
|
649
|
+
* framework plugins.
|
|
650
|
+
* - `per-package`: splits dependencies in `node_modules` by npm package.
|
|
651
|
+
* - `single-vendor`: splits all `node_modules` dependencies into one vendor chunk.
|
|
652
|
+
* - `none`: disables Rsbuild preset rules.
|
|
653
|
+
*/ export type SplitChunksPreset = 'default' | 'single-vendor' | 'per-package' | 'none';
|
|
654
|
+
export type SplitChunksConfig = Rspack.OptimizationSplitChunksOptions & {
|
|
655
|
+
preset?: SplitChunksPreset;
|
|
656
|
+
};
|
|
657
|
+
export type NormalizedSplitChunksConfig = SplitChunksConfig;
|
|
658
|
+
export type ForceSplitting = RegExp[] | Record<string, RegExp>;
|
|
659
|
+
export interface BaseSplitRules {
|
|
660
|
+
strategy?: string;
|
|
661
|
+
forceSplitting?: ForceSplitting;
|
|
662
|
+
override?: SplitChunks;
|
|
663
|
+
}
|
|
664
|
+
export interface BaseChunkSplit extends BaseSplitRules {
|
|
665
|
+
strategy?: 'split-by-module' | 'split-by-experience' | 'all-in-one' | 'single-vendor';
|
|
666
|
+
}
|
|
667
|
+
export interface SplitBySize extends BaseSplitRules {
|
|
668
|
+
strategy: 'split-by-size';
|
|
669
|
+
minSize?: number;
|
|
670
|
+
maxSize?: number;
|
|
671
|
+
}
|
|
672
|
+
export interface SplitCustom extends BaseSplitRules {
|
|
673
|
+
strategy: 'custom';
|
|
674
|
+
splitChunks?: SplitChunks;
|
|
675
|
+
}
|
|
676
|
+
export type ChunkSplit = BaseChunkSplit | SplitBySize | SplitCustom;
|
|
677
|
+
export type DistPathConfig = {
|
|
678
|
+
/**
|
|
679
|
+
* The root directory of all files.
|
|
680
|
+
* @default 'dist'
|
|
681
|
+
**/ root?: string;
|
|
682
|
+
/**
|
|
683
|
+
* The output directory of JavaScript files.
|
|
684
|
+
* @default 'static/js'
|
|
685
|
+
*/ js?: string;
|
|
686
|
+
/**
|
|
687
|
+
* The output directory of async JavaScript files.
|
|
688
|
+
* @default 'static/js/async'
|
|
689
|
+
*/ jsAsync?: string;
|
|
690
|
+
/**
|
|
691
|
+
* The output directory of CSS files.
|
|
692
|
+
* @default 'static/css'
|
|
693
|
+
*/ css?: string;
|
|
694
|
+
/**
|
|
695
|
+
* The output directory of async CSS files.
|
|
696
|
+
* @default 'static/css/async'
|
|
697
|
+
*/ cssAsync?: string;
|
|
698
|
+
/**
|
|
699
|
+
* The output directory of SVG images.
|
|
700
|
+
* @default 'static/svg'
|
|
701
|
+
*/ svg?: string;
|
|
702
|
+
/**
|
|
703
|
+
* The output directory of font files.
|
|
704
|
+
* @default 'static/font'
|
|
705
|
+
*/ font?: string;
|
|
706
|
+
/**
|
|
707
|
+
* The output directory of HTML files.
|
|
708
|
+
* @default './'
|
|
709
|
+
*/ html?: string;
|
|
710
|
+
/**
|
|
711
|
+
* The output directory of Wasm files.
|
|
712
|
+
* @default 'static/wasm'
|
|
713
|
+
*/ wasm?: string;
|
|
714
|
+
/**
|
|
715
|
+
* The output directory of non-SVG images.
|
|
716
|
+
* @default 'static/image'
|
|
717
|
+
*/ image?: string;
|
|
718
|
+
/**
|
|
719
|
+
* The output directory of media resources, such as videos.
|
|
720
|
+
* @default 'static/media'
|
|
721
|
+
*/ media?: string;
|
|
722
|
+
/**
|
|
723
|
+
* The output directory of assets, except for above (image, svg, font, html, wasm...)
|
|
724
|
+
* @default 'static/assets'
|
|
725
|
+
*/ assets?: string;
|
|
726
|
+
/**
|
|
727
|
+
* The output directory of favicon.
|
|
728
|
+
* @default './'
|
|
729
|
+
*/ favicon?: string;
|
|
730
|
+
};
|
|
731
|
+
export type FilenameConfig = {
|
|
732
|
+
/**
|
|
733
|
+
* The name of HTML files.
|
|
734
|
+
* @default `[name].html`
|
|
735
|
+
*/ html?: string;
|
|
736
|
+
/**
|
|
737
|
+
* The name of the JavaScript files.
|
|
738
|
+
* @default
|
|
739
|
+
* - dev: '[name].js'
|
|
740
|
+
* - prod: '[name].[contenthash:10].js'
|
|
741
|
+
*/ js?: Rspack.Filename;
|
|
742
|
+
/**
|
|
743
|
+
* The name of the CSS files.
|
|
744
|
+
* @default
|
|
745
|
+
* - dev: '[name].css'
|
|
746
|
+
* - prod: '[name].[contenthash:10].css'
|
|
747
|
+
*/ css?: Rspack.CssFilename;
|
|
748
|
+
/**
|
|
749
|
+
* The name of the SVG images.
|
|
750
|
+
* @default '[name].[contenthash:10].svg'
|
|
751
|
+
*/ svg?: Rspack.AssetModuleFilename;
|
|
752
|
+
/**
|
|
753
|
+
* The name of the font files.
|
|
754
|
+
* @default '[name].[contenthash:10][ext]'
|
|
755
|
+
*/ font?: Rspack.AssetModuleFilename;
|
|
756
|
+
/**
|
|
757
|
+
* The name of non-SVG images.
|
|
758
|
+
* @default '[name].[contenthash:10][ext]'
|
|
759
|
+
*/ image?: Rspack.AssetModuleFilename;
|
|
760
|
+
/**
|
|
761
|
+
* The name of media assets, such as video.
|
|
762
|
+
* @default '[name].[contenthash:10][ext]'
|
|
763
|
+
*/ media?: Rspack.AssetModuleFilename;
|
|
764
|
+
/**
|
|
765
|
+
* The name of Wasm files.
|
|
766
|
+
* @default '[hash].module.wasm'
|
|
767
|
+
*/ wasm?: Rspack.WebassemblyModuleFilename;
|
|
768
|
+
/**
|
|
769
|
+
* The name of other assets, except for above (image, svg, font, html, wasm...)
|
|
770
|
+
* @default '[name].[contenthash:10][ext]'
|
|
771
|
+
*/ assets?: Rspack.AssetModuleFilename;
|
|
772
|
+
};
|
|
773
|
+
export type FilenameHash = boolean | string | {
|
|
774
|
+
/**
|
|
775
|
+
* Controls whether to add filename hash.
|
|
776
|
+
* - `true`: JavaScript and CSS filenames include hash in production mode.
|
|
777
|
+
* - `false`: Disable filename hash.
|
|
778
|
+
* - `'always'`: JavaScript and CSS filenames include hash in all modes.
|
|
779
|
+
* @default true
|
|
780
|
+
*/ enable?: boolean | 'always';
|
|
781
|
+
/**
|
|
782
|
+
* The filename hash format.
|
|
783
|
+
* @default 'contenthash:10'
|
|
784
|
+
*/ format?: string;
|
|
785
|
+
};
|
|
786
|
+
export type DataUriLimit = {
|
|
787
|
+
/**
|
|
788
|
+
* The data URI limit of the SVG image.
|
|
789
|
+
* @default 4096
|
|
790
|
+
*/ svg?: number;
|
|
791
|
+
/**
|
|
792
|
+
* The data URI limit of the font file.
|
|
793
|
+
* @default 4096
|
|
794
|
+
*/ font?: number;
|
|
795
|
+
/**
|
|
796
|
+
* The data URI limit of non-SVG images.
|
|
797
|
+
* @default 4096
|
|
798
|
+
*/ image?: number;
|
|
799
|
+
/**
|
|
800
|
+
* The data URI limit of media resources such as videos.
|
|
801
|
+
* @default 4096
|
|
802
|
+
*/ media?: number;
|
|
803
|
+
/**
|
|
804
|
+
* The data URI limit of other static assets.
|
|
805
|
+
* @default 4096
|
|
806
|
+
*/ assets?: number;
|
|
807
|
+
};
|
|
808
|
+
export type Charset = 'ascii' | 'utf8';
|
|
809
|
+
export type LegalComments = 'none' | 'inline' | 'linked';
|
|
810
|
+
export type NormalizedDataUriLimit = Required<DataUriLimit>;
|
|
811
|
+
export type Polyfill = 'usage' | 'entry' | 'off';
|
|
812
|
+
export type SourceMapExtractTarget = {
|
|
813
|
+
/**
|
|
814
|
+
* Include matched files whose existing source maps should be extracted.
|
|
815
|
+
*/ include?: RuleSetCondition[];
|
|
816
|
+
/**
|
|
817
|
+
* Exclude matched files whose existing source maps should not be extracted.
|
|
818
|
+
*/ exclude?: RuleSetCondition[];
|
|
819
|
+
};
|
|
820
|
+
export type SourceMapExtractOptions = SourceMapExtractTarget & {
|
|
821
|
+
/**
|
|
822
|
+
* Custom rule condition for matching files whose existing source maps should
|
|
823
|
+
* be extracted.
|
|
824
|
+
* @default /\.(?:js|mjs|cjs|jsx)$/
|
|
825
|
+
*/ test?: RuleSetCondition;
|
|
826
|
+
/**
|
|
827
|
+
* Whether to extract existing source maps from matching JavaScript files.
|
|
828
|
+
* @deprecated Use the flat `test`, `include`, and `exclude` fields instead.
|
|
829
|
+
*/ js?: boolean | SourceMapExtractTarget;
|
|
830
|
+
};
|
|
831
|
+
export type SourceMapExtract = boolean | SourceMapExtractOptions;
|
|
832
|
+
export type SourceMap = {
|
|
833
|
+
/**
|
|
834
|
+
* The source map type for JavaScript files.
|
|
835
|
+
* @default isDev ? 'cheap-module-source-map' : false
|
|
836
|
+
*/ js?: Rspack.Configuration['devtool'];
|
|
837
|
+
/**
|
|
838
|
+
* Whether to generate source map for CSS files.
|
|
839
|
+
* @default false
|
|
840
|
+
*/ css?: boolean;
|
|
841
|
+
/**
|
|
842
|
+
* Whether to extract existing source maps from matching input files.
|
|
843
|
+
* This is useful when a third-party package already ships both output files
|
|
844
|
+
* and source map files.
|
|
845
|
+
* @default false
|
|
846
|
+
*/ extract?: SourceMapExtract;
|
|
847
|
+
};
|
|
848
|
+
export type CSSModulesLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
849
|
+
export type CSSModules = {
|
|
850
|
+
/**
|
|
851
|
+
* Allows CSS Modules to be automatically enabled based on their filenames.
|
|
852
|
+
* @default true
|
|
853
|
+
*/ auto?: CSSLoaderModulesOptions['auto'];
|
|
854
|
+
/**
|
|
855
|
+
* Allows exporting names from global class names, so you can use them via import.
|
|
856
|
+
* @default false
|
|
857
|
+
*/ exportGlobals?: boolean;
|
|
858
|
+
/**
|
|
859
|
+
* Style of exported class names.
|
|
860
|
+
* @default 'camelCase'
|
|
861
|
+
*/ exportLocalsConvention?: CSSModulesLocalsConvention;
|
|
862
|
+
/**
|
|
863
|
+
* Set the local ident name of CSS Modules.
|
|
864
|
+
* @default isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'
|
|
865
|
+
*/ localIdentName?: string;
|
|
866
|
+
/**
|
|
867
|
+
* Controls the level of compilation applied to the input styles.
|
|
868
|
+
* @default 'local'
|
|
869
|
+
*/ mode?: CSSLoaderModulesOptions['mode'];
|
|
870
|
+
/**
|
|
871
|
+
* Whether to enable ES modules named export for locals.
|
|
872
|
+
* @default false
|
|
873
|
+
*/ namedExport?: boolean;
|
|
874
|
+
};
|
|
875
|
+
export type Minify = boolean | {
|
|
876
|
+
/**
|
|
877
|
+
* Whether to enable minification for JavaScript bundles.
|
|
878
|
+
* - `true`: Enabled in production mode.
|
|
879
|
+
* - `false`: Disabled in all modes.
|
|
880
|
+
* - `'always'`: Enabled in all modes.
|
|
881
|
+
* @default true
|
|
882
|
+
*/ js?: boolean | 'always';
|
|
883
|
+
/**
|
|
884
|
+
* Minimizer options of JavaScript, which will be passed to SWC.
|
|
885
|
+
* When using an array, each item registers a separate minimizer and the first matching item
|
|
886
|
+
* applies to each JavaScript asset.
|
|
887
|
+
* @default {}
|
|
888
|
+
*/ jsOptions?: OneOrMany<SwcJsMinimizerRspackPluginOptions>;
|
|
889
|
+
/**
|
|
890
|
+
* Whether to enable minification for CSS bundles.
|
|
891
|
+
* - `true`: Enabled in production mode.
|
|
892
|
+
* - `false`: Disabled in all modes.
|
|
893
|
+
* - `'always'`: Enabled in all modes.
|
|
894
|
+
* @default true
|
|
895
|
+
*/ css?: boolean | 'always';
|
|
896
|
+
/**
|
|
897
|
+
* Minimizer options of CSS, which will be passed to LightningCSS.
|
|
898
|
+
* When using an array, each item registers a separate minimizer and the first matching item
|
|
899
|
+
* applies to each CSS asset.
|
|
900
|
+
* @default inherit from `tools.lightningcssLoader` config
|
|
901
|
+
*/ cssOptions?: OneOrMany<LightningCssMinimizerRspackPluginOptions>;
|
|
902
|
+
};
|
|
903
|
+
export type InlineChunkTestFunction = (params: {
|
|
904
|
+
size: number;
|
|
905
|
+
name: string;
|
|
906
|
+
}) => boolean;
|
|
907
|
+
export type InlineChunkTest = RegExp | InlineChunkTestFunction;
|
|
908
|
+
export type InlineChunkConfig = boolean | InlineChunkTest | {
|
|
909
|
+
enable?: boolean | 'auto';
|
|
910
|
+
test: InlineChunkTest;
|
|
911
|
+
};
|
|
912
|
+
export type ManifestByEntry = {
|
|
913
|
+
/**
|
|
914
|
+
* Files that are required during the initial load of the entry.
|
|
915
|
+
*/ initial?: {
|
|
916
|
+
/** Initial JavaScript files for this entry. */ js?: string[];
|
|
917
|
+
/** Initial CSS files for this entry. */ css?: string[];
|
|
918
|
+
};
|
|
919
|
+
/**
|
|
920
|
+
* Files that may be loaded asynchronously.
|
|
921
|
+
* Usually code-split chunks or lazily loaded chunks.
|
|
922
|
+
*/ async?: {
|
|
923
|
+
/** Async JavaScript files for this entry. */ js?: string[];
|
|
924
|
+
/** Async CSS files for this entry. */ css?: string[];
|
|
925
|
+
};
|
|
926
|
+
/** HTML files generated for this entry, if any. */ html?: string[];
|
|
927
|
+
/**
|
|
928
|
+
* Additional assets associated with this entry.
|
|
929
|
+
* For example images、fonts、source maps and other non JS or CSS files.
|
|
930
|
+
*/ assets?: string[];
|
|
931
|
+
};
|
|
932
|
+
export type ManifestData = {
|
|
933
|
+
/**
|
|
934
|
+
* A flat list of all emitted asset files.
|
|
935
|
+
*/ allFiles: string[];
|
|
936
|
+
/**
|
|
937
|
+
* Maps each entry name to its associated output files.
|
|
938
|
+
*/ entries: Record<string, ManifestByEntry>;
|
|
939
|
+
/**
|
|
940
|
+
* Subresource Integrity (SRI) hashes for emitted assets.
|
|
941
|
+
* The key is the asset file path, and the value is its integrity hash.
|
|
942
|
+
* This field is available only when the `security.sri` option is enabled.
|
|
943
|
+
*/ integrity: Record<string, string>;
|
|
944
|
+
};
|
|
945
|
+
export type ManifestObjectConfig = {
|
|
946
|
+
/**
|
|
947
|
+
* The filename or path of the manifest file.
|
|
948
|
+
* The manifest file will be emitted to the output directory.
|
|
949
|
+
* @default 'manifest.json'
|
|
950
|
+
*/ filename?: string;
|
|
951
|
+
/**
|
|
952
|
+
* A custom function to generate the content of the manifest file.
|
|
953
|
+
*/ generate?: (params: {
|
|
954
|
+
files: FileDescriptor[];
|
|
955
|
+
manifestData: ManifestData;
|
|
956
|
+
}) => Record<string, unknown>;
|
|
957
|
+
/**
|
|
958
|
+
* Allows you to filter the files included in the manifest.
|
|
959
|
+
* The function receives a `file` parameter and returns `true` to keep the file,
|
|
960
|
+
* or `false` to exclude it.
|
|
961
|
+
* @default (file: FileDescriptor) => !file.name.endsWith('.LICENSE.txt')
|
|
962
|
+
*/ filter?: (file: FileDescriptor) => boolean;
|
|
963
|
+
/**
|
|
964
|
+
* Controls whether the generated manifest includes the static asset prefix in file paths.
|
|
965
|
+
* The prefix is taken from `dev.assetPrefix` and `output.assetPrefix`.
|
|
966
|
+
* @default true
|
|
967
|
+
*/ prefix?: boolean;
|
|
968
|
+
};
|
|
969
|
+
export type ManifestConfig = string | boolean | ManifestObjectConfig;
|
|
970
|
+
export type CleanDistPathObject = {
|
|
971
|
+
/**
|
|
972
|
+
* Whether to clean up all files under the output directory before the build starts.
|
|
973
|
+
* @default 'auto'
|
|
974
|
+
*/ enable?: boolean | 'auto';
|
|
975
|
+
/**
|
|
976
|
+
* Specify the files to keep in the output directory.
|
|
977
|
+
* If the file's absolute path matches the regular expression in `keep`, the file
|
|
978
|
+
* will not be removed.
|
|
979
|
+
* @default undefined
|
|
980
|
+
*/ keep?: RegExp[];
|
|
981
|
+
};
|
|
982
|
+
export type CleanDistPath = boolean | 'auto' | CleanDistPathObject;
|
|
983
|
+
export type AutoExternalExclude = OneOrMany<string | RegExp>;
|
|
984
|
+
export type AutoExternal = boolean | {
|
|
985
|
+
/**
|
|
986
|
+
* Whether to automatically externalize dependencies of type `dependencies`.
|
|
987
|
+
* @default true
|
|
988
|
+
*/ dependencies?: boolean;
|
|
989
|
+
/**
|
|
990
|
+
* Whether to automatically externalize dependencies of type `optionalDependencies`.
|
|
991
|
+
* @default true
|
|
992
|
+
*/ optionalDependencies?: boolean;
|
|
993
|
+
/**
|
|
994
|
+
* Whether to automatically externalize dependencies of type `peerDependencies`.
|
|
995
|
+
* @default true
|
|
996
|
+
*/ peerDependencies?: boolean;
|
|
997
|
+
/**
|
|
998
|
+
* Whether to automatically externalize dependencies of type `devDependencies`.
|
|
999
|
+
* @default false
|
|
1000
|
+
*/ devDependencies?: boolean;
|
|
1001
|
+
/**
|
|
1002
|
+
* Specify the package.json file path(s) used to collect dependencies.
|
|
1003
|
+
* Relative paths are resolved from the Rsbuild root directory.
|
|
1004
|
+
* @default '<root>/package.json'
|
|
1005
|
+
*/ packageJson?: string | string[];
|
|
1006
|
+
/**
|
|
1007
|
+
* Prevent matched packages from being automatically externalized.
|
|
1008
|
+
* Strings match package names exactly, and regular expressions test package names.
|
|
1009
|
+
* @default undefined
|
|
1010
|
+
*/ exclude?: AutoExternalExclude;
|
|
1011
|
+
};
|
|
1012
|
+
export interface OutputConfig {
|
|
1013
|
+
/**
|
|
1014
|
+
* Setting the build target for Rsbuild.
|
|
1015
|
+
* @default 'web'
|
|
1016
|
+
*/ target?: RsbuildTarget;
|
|
1017
|
+
/**
|
|
1018
|
+
* Use this option to specify which modules should not be bundled by Rsbuild, and instead
|
|
1019
|
+
* use implementations provided by the external environment.
|
|
1020
|
+
* For more information, please see: [Rspack Externals](https://rspack.rs/config/externals)
|
|
1021
|
+
* @default undefined
|
|
1022
|
+
*/ externals?: Externals;
|
|
1023
|
+
/**
|
|
1024
|
+
* Automatically externalize dependencies declared in the root package.json.
|
|
1025
|
+
* This option will generate `externals` rules for matching dependencies and their subpath imports.
|
|
1026
|
+
* @default false
|
|
1027
|
+
*/ autoExternal?: AutoExternal;
|
|
1028
|
+
/**
|
|
1029
|
+
* Set the directory of the output files.
|
|
1030
|
+
* Rsbuild will emit files to the specified subdirectory according to the file type.
|
|
1031
|
+
* - `string`: Set the root output directory to a specific path, equivalent to `distPath.root`.
|
|
1032
|
+
* - `object`: Set the output directory for each file type.
|
|
1033
|
+
*/ distPath?: string | DistPathConfig;
|
|
1034
|
+
/**
|
|
1035
|
+
* Sets the filename of output files.
|
|
1036
|
+
*/ filename?: FilenameConfig;
|
|
1037
|
+
/**
|
|
1038
|
+
* Specify the character encoding format for output files.
|
|
1039
|
+
* Can be `ascii` or `utf8`.
|
|
1040
|
+
* @default 'utf8'
|
|
1041
|
+
*/ charset?: Charset;
|
|
1042
|
+
/**
|
|
1043
|
+
* Configure how the polyfill is injected.
|
|
1044
|
+
* @default 'off'
|
|
1045
|
+
*/ polyfill?: Polyfill;
|
|
1046
|
+
/**
|
|
1047
|
+
* When using CDN in the production,
|
|
1048
|
+
* you can use this option to set the URL prefix of static assets,
|
|
1049
|
+
* similar to the `output.publicPath` config of Rspack.
|
|
1050
|
+
* `auto` means use a relative path based on file location.
|
|
1051
|
+
* @default `server.base`
|
|
1052
|
+
*/ assetPrefix?: LiteralUnion<'auto', string>;
|
|
1053
|
+
/**
|
|
1054
|
+
* Set the size threshold to inline static assets such as images and fonts.
|
|
1055
|
+
* By default, static assets will be Base64 encoded and inline into the page if
|
|
1056
|
+
* the size is less than 4KiB.
|
|
1057
|
+
* @default { svg: 4096, font: 4096, image: 4096, media: 4096, assets: 4096 }
|
|
1058
|
+
*/ dataUriLimit?: number | DataUriLimit;
|
|
1059
|
+
/**
|
|
1060
|
+
* Configure how to handle the legal comment.
|
|
1061
|
+
* A "legal comment" is considered to be any statement-level comment in JS or rule-level
|
|
1062
|
+
* comment in CSS that contains @license or @preserve or that starts with //! or /\*!.
|
|
1063
|
+
* These comments are preserved in output files by default since that follows the intent
|
|
1064
|
+
* of the original authors of the code.
|
|
1065
|
+
* @default 'linked'
|
|
1066
|
+
*/ legalComments?: LegalComments;
|
|
1067
|
+
/**
|
|
1068
|
+
* Whether to clean up all files under the output directory before the build starts.
|
|
1069
|
+
* @default 'auto'
|
|
1070
|
+
*/ cleanDistPath?: CleanDistPath;
|
|
1071
|
+
/**
|
|
1072
|
+
* Allow to custom CSS Modules options.
|
|
1073
|
+
*/ cssModules?: CSSModules;
|
|
1074
|
+
/**
|
|
1075
|
+
* Configure whether to enable code minification in production mode, or to configure
|
|
1076
|
+
* minimizer options.
|
|
1077
|
+
* @default true
|
|
1078
|
+
*/ minify?: Minify;
|
|
1079
|
+
/**
|
|
1080
|
+
* Configure how to generate the manifest file.
|
|
1081
|
+
* - `true`: Generate a manifest file named `manifest.json` in the output directory.
|
|
1082
|
+
* - `false`: Do not generate the manifest file.
|
|
1083
|
+
* - `string`: Generate a manifest file with the specified filename or path.
|
|
1084
|
+
* - `object`: Generate a manifest file with the specified options.
|
|
1085
|
+
* @default false
|
|
1086
|
+
*/ manifest?: ManifestConfig;
|
|
1087
|
+
/**
|
|
1088
|
+
* Whether to output JavaScript files in ES modules format.
|
|
1089
|
+
* @default true when `output.target` is `node`, otherwise `false`
|
|
1090
|
+
*/ module?: boolean;
|
|
1091
|
+
/**
|
|
1092
|
+
* Whether to generate source map files, and which format of source map to generate.
|
|
1093
|
+
*
|
|
1094
|
+
* @default
|
|
1095
|
+
* ```js
|
|
1096
|
+
* const defaultSourceMap = {
|
|
1097
|
+
* js: isDev ? 'cheap-module-source-map' : false,
|
|
1098
|
+
* css: false,
|
|
1099
|
+
* extract: false,
|
|
1100
|
+
* };
|
|
1101
|
+
* ```
|
|
1102
|
+
*/ sourceMap?: boolean | SourceMap;
|
|
1103
|
+
/**
|
|
1104
|
+
* Whether to add filename hash.
|
|
1105
|
+
* - `true`: JavaScript and CSS filenames include hash in production mode, while other assets
|
|
1106
|
+
* always include hash in all modes.
|
|
1107
|
+
* - `false`: Disable filename hash.
|
|
1108
|
+
* - `string`: Enable filename hash and customize the hash format, such as `'contenthash:16'`.
|
|
1109
|
+
* - `object`: An object to configure filename hash behavior.
|
|
1110
|
+
* @default true
|
|
1111
|
+
*/ filenameHash?: FilenameHash;
|
|
1112
|
+
/**
|
|
1113
|
+
* Whether to inline output scripts files (.js files) into HTML with `<script>` tags.
|
|
1114
|
+
* @default false
|
|
1115
|
+
*/ inlineScripts?: InlineChunkConfig;
|
|
1116
|
+
/**
|
|
1117
|
+
* Whether to inline output style files (.css files) into html with `<style>` tags.
|
|
1118
|
+
* @default false
|
|
1119
|
+
*/ inlineStyles?: InlineChunkConfig;
|
|
1120
|
+
/**
|
|
1121
|
+
* Whether to inject styles into the DOM via `style-loader`.
|
|
1122
|
+
* @default false
|
|
1123
|
+
*/ injectStyles?: boolean;
|
|
1124
|
+
/**
|
|
1125
|
+
* Specifies the range of target browsers that the project is compatible with.
|
|
1126
|
+
* This value will be used by [SWC](https://github.com/swc-project/swc) and
|
|
1127
|
+
* [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to identify
|
|
1128
|
+
* the JavaScript syntax that need to be transformed and the CSS browser prefixes
|
|
1129
|
+
* that need to be added.
|
|
1130
|
+
* @default undefined
|
|
1131
|
+
*/ overrideBrowserslist?: string[];
|
|
1132
|
+
/**
|
|
1133
|
+
* Copies the specified file or directory to the dist directory.
|
|
1134
|
+
* @default undefined
|
|
1135
|
+
*/ copy?: CopyRspackPluginOptions | CopyRspackPluginOptions['patterns'];
|
|
1136
|
+
/**
|
|
1137
|
+
* Whether to emit static assets such as image, font, etc.
|
|
1138
|
+
* Return `false` to avoid outputting unnecessary assets for some scenarios such as SSR.
|
|
1139
|
+
* @default true
|
|
1140
|
+
*/ emitAssets?: boolean;
|
|
1141
|
+
/**
|
|
1142
|
+
* Whether to emit CSS to the output bundles.
|
|
1143
|
+
* If `false`, the CSS will not be extracted to separate files or injected into the
|
|
1144
|
+
* JavaScript bundles via `output.injectStyles`.
|
|
1145
|
+
* @default `true` when `output.target` is `web`, otherwise `false`
|
|
1146
|
+
*/ emitCss?: boolean;
|
|
1147
|
+
}
|
|
1148
|
+
export interface NormalizedOutputConfig extends OutputConfig {
|
|
1149
|
+
target: RsbuildTarget;
|
|
1150
|
+
filename: FilenameConfig;
|
|
1151
|
+
distPath: Optional<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'>;
|
|
1152
|
+
polyfill: Polyfill;
|
|
1153
|
+
sourceMap: boolean | {
|
|
1154
|
+
js?: Rspack.Configuration['devtool'];
|
|
1155
|
+
css: boolean;
|
|
1156
|
+
extract: SourceMapExtract;
|
|
1157
|
+
};
|
|
1158
|
+
cleanDistPath: CleanDistPath;
|
|
1159
|
+
filenameHash: FilenameHash;
|
|
1160
|
+
assetPrefix: string;
|
|
1161
|
+
dataUriLimit: number | NormalizedDataUriLimit;
|
|
1162
|
+
manifest: ManifestConfig;
|
|
1163
|
+
inlineScripts: InlineChunkConfig;
|
|
1164
|
+
inlineStyles: InlineChunkConfig;
|
|
1165
|
+
injectStyles: boolean;
|
|
1166
|
+
cssModules: {
|
|
1167
|
+
auto: CSSModules['auto'];
|
|
1168
|
+
namedExport: boolean;
|
|
1169
|
+
exportGlobals: boolean;
|
|
1170
|
+
exportLocalsConvention: CSSModulesLocalsConvention;
|
|
1171
|
+
localIdentName?: string;
|
|
1172
|
+
mode?: CSSModules['mode'];
|
|
1173
|
+
};
|
|
1174
|
+
emitAssets: boolean;
|
|
1175
|
+
}
|
|
1176
|
+
export type CrossOrigin = 'anonymous' | 'use-credentials';
|
|
1177
|
+
export type ScriptInject = boolean | 'body' | 'head';
|
|
1178
|
+
export type ScriptLoading = 'defer' | 'module' | 'blocking';
|
|
1179
|
+
export type OutputStructure = 'flat' | 'nested';
|
|
1180
|
+
/**
|
|
1181
|
+
* Custom meta tag attributes.
|
|
1182
|
+
* Key is the attribute name.
|
|
1183
|
+
* Value is the attribute value, as a string or boolean.
|
|
1184
|
+
*
|
|
1185
|
+
* @example
|
|
1186
|
+
* {
|
|
1187
|
+
* name: 'viewport',
|
|
1188
|
+
* content: 'width=500, initial-scale=1',
|
|
1189
|
+
* }
|
|
1190
|
+
*/ export type MetaAttrs = Record<string, string | boolean>;
|
|
1191
|
+
/**
|
|
1192
|
+
* Meta options in name-content form.
|
|
1193
|
+
* Key is the meta name, such as `viewport`, `description`, or `robots`.
|
|
1194
|
+
* The value can be:
|
|
1195
|
+
* - `string`: the content of the meta tag
|
|
1196
|
+
* - `false`: explicitly disables the meta tag
|
|
1197
|
+
* - `MetaAttrs`: a set of custom meta attributes
|
|
1198
|
+
*
|
|
1199
|
+
* @example
|
|
1200
|
+
* {
|
|
1201
|
+
* viewport: 'width=device-width, initial-scale=1',
|
|
1202
|
+
* description: 'My awesome website',
|
|
1203
|
+
* robots: false,
|
|
1204
|
+
* }
|
|
1205
|
+
*/ export type MetaOptions = Record<string, string | false | MetaAttrs>;
|
|
1206
|
+
export type HtmlBasicTag = {
|
|
1207
|
+
/**
|
|
1208
|
+
* The HTML tag name to be generated. Should be a valid HTML element name.
|
|
1209
|
+
* @example
|
|
1210
|
+
* - `'script'` for JavaScript files
|
|
1211
|
+
* - `'link'` for stylesheets or external resources
|
|
1212
|
+
* - `'meta'` for metadata
|
|
1213
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element
|
|
1214
|
+
*/ tag: string;
|
|
1215
|
+
/**
|
|
1216
|
+
* HTML attributes to be applied to the tag.
|
|
1217
|
+
* - `string` values will be rendered as `attribute="value"`
|
|
1218
|
+
* - `true` renders as boolean attribute (e.g., `<input disabled>`)
|
|
1219
|
+
* - `false` or `null` or `undefined` values will omit the attribute
|
|
1220
|
+
*
|
|
1221
|
+
* @example
|
|
1222
|
+
* // String attributes
|
|
1223
|
+
* attrs: {
|
|
1224
|
+
* src: 'https://example.com/script.js',
|
|
1225
|
+
* type: 'text/javascript',
|
|
1226
|
+
* }
|
|
1227
|
+
* // Result: <script src="https://example.com/script.js" type="text/javascript">
|
|
1228
|
+
|
|
1229
|
+
* // Boolean attributes
|
|
1230
|
+
* attrs: {
|
|
1231
|
+
* async: true, // <script async>
|
|
1232
|
+
* defer: false, // attribute omitted
|
|
1233
|
+
* }
|
|
1234
|
+
* // Result: <script async>
|
|
1235
|
+
*/ attrs?: Record<string, string | boolean | null | undefined>;
|
|
1236
|
+
/**
|
|
1237
|
+
* The innerHTML content of the tag. The content is inserted as-is without
|
|
1238
|
+
* HTML escaping, so ensure it's safe to prevent XSS vulnerabilities.
|
|
1239
|
+
*/ children?: string;
|
|
1240
|
+
/**
|
|
1241
|
+
* The metadata object for tags, used to store additional information about tags.
|
|
1242
|
+
* `metadata` does not affect the generated HTML content.
|
|
1243
|
+
* @default undefined
|
|
1244
|
+
*/ metadata?: Record<string, any>;
|
|
1245
|
+
};
|
|
1246
|
+
export type HtmlTag = HtmlBasicTag & {
|
|
1247
|
+
/**
|
|
1248
|
+
* Controls whether to add a hash query parameter to asset URLs for cache invalidation.
|
|
1249
|
+
* Only affects the `src` attribute of the `script` tag and the `href` attribute of the `link` tag.
|
|
1250
|
+
* - `false`: No hash query
|
|
1251
|
+
* - `true`: Generate hash based on HTML content
|
|
1252
|
+
* - `string`: Uses a custom hash string
|
|
1253
|
+
* - `function`: Custom hash generation via a function
|
|
1254
|
+
* @default false
|
|
1255
|
+
*/ hash?: boolean | string | ((url: string, hash: string) => string);
|
|
1256
|
+
/**
|
|
1257
|
+
* Controls whether to prepend the asset prefix to resource URLs.
|
|
1258
|
+
* Only affects the `src` attribute of the `script` tag and the `href` attribute of the `link` tag.
|
|
1259
|
+
* - `true`: Prepends asset prefix to the URL
|
|
1260
|
+
* - `false`: Uses the URL as-is
|
|
1261
|
+
* - `string`: Uses a custom prefix
|
|
1262
|
+
* - `function`: Custom path transformation via a function
|
|
1263
|
+
* @default true
|
|
1264
|
+
*/ publicPath?: boolean | string | ((url: string, publicPath: string) => string);
|
|
1265
|
+
/**
|
|
1266
|
+
* Defines the injection position relative to existing tags.
|
|
1267
|
+
* - `true`: Insert after existing tags
|
|
1268
|
+
* - `false`: Insert before existing tags
|
|
1269
|
+
* @default true
|
|
1270
|
+
*/ append?: boolean;
|
|
1271
|
+
/**
|
|
1272
|
+
* Specifies whether to inject the tag into the HTML `<head>` element.
|
|
1273
|
+
* - `true`: Inject into `<head>`
|
|
1274
|
+
* - `false`: Inject into `<body>`
|
|
1275
|
+
* @default Auto-detect: `true` for head-allowed elements, `false` otherwise
|
|
1276
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head#see_also
|
|
1277
|
+
*/ head?: boolean;
|
|
1278
|
+
};
|
|
1279
|
+
export type HtmlTagContext = {
|
|
1280
|
+
hash: string;
|
|
1281
|
+
entryName: string;
|
|
1282
|
+
outputName: string;
|
|
1283
|
+
publicPath: string;
|
|
1284
|
+
};
|
|
1285
|
+
export type HtmlTagHandler = (tags: HtmlTag[], context: HtmlTagContext) => HtmlTag[] | void;
|
|
1286
|
+
export type HtmlTagDescriptor = HtmlTag | HtmlTagHandler;
|
|
1287
|
+
type ChainedHtmlOption<O> = OneOrMany<O | ((context: {
|
|
1288
|
+
value: O;
|
|
1289
|
+
entryName: string;
|
|
1290
|
+
}) => MaybePromise<O | void>)>;
|
|
1291
|
+
export type AppIconItem = {
|
|
1292
|
+
/**
|
|
1293
|
+
* The path to the icon, can be a URL, an absolute file path,
|
|
1294
|
+
* or a relative path to the project root.
|
|
1295
|
+
*/ src: string;
|
|
1296
|
+
/**
|
|
1297
|
+
* The size of the icon.
|
|
1298
|
+
*/ size: number;
|
|
1299
|
+
/**
|
|
1300
|
+
* Specifies the intended target for which the icon should be generated.
|
|
1301
|
+
* - `apple-touch-icon` for iOS system.
|
|
1302
|
+
* - `web-app-manifest` for web application manifest.
|
|
1303
|
+
*/ target?: 'apple-touch-icon' | 'web-app-manifest';
|
|
1304
|
+
/**
|
|
1305
|
+
* A case-sensitive keyword string that specifies one or more contexts in
|
|
1306
|
+
* which the icon can be used by the browser or operating system.
|
|
1307
|
+
* This field is only effective when the `target` is `'web-app-manifest'`.
|
|
1308
|
+
*
|
|
1309
|
+
* The possible properties include:
|
|
1310
|
+
* - `'monochrome'`: Indicates that the icon is intended to be used as a
|
|
1311
|
+
* monochrome icon with a solid fill.
|
|
1312
|
+
* - `'maskable'`: Indicates that the icon is designed with icon masks and
|
|
1313
|
+
* safe zone in mind.
|
|
1314
|
+
* - `'any'`: Indicates that the icon can be used in any context. This is
|
|
1315
|
+
* the default value.
|
|
1316
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps/Manifest/Reference/icons#purpose
|
|
1317
|
+
*/ purpose?: LiteralUnion<'any' | 'maskable' | 'monochrome', string>;
|
|
1318
|
+
};
|
|
1319
|
+
export type AppIcon = {
|
|
1320
|
+
/**
|
|
1321
|
+
* The name of the application.
|
|
1322
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Manifest/name
|
|
1323
|
+
*/ name?: string;
|
|
1324
|
+
/**
|
|
1325
|
+
* The list of icons.
|
|
1326
|
+
*/ icons: AppIconItem[];
|
|
1327
|
+
/**
|
|
1328
|
+
* The filename of the manifest file.
|
|
1329
|
+
* @default 'manifest.webmanifest'
|
|
1330
|
+
*/ filename?: string;
|
|
1331
|
+
};
|
|
1332
|
+
type HtmlImplementation = 'js' | 'native';
|
|
1333
|
+
export interface HtmlConfig {
|
|
1334
|
+
/**
|
|
1335
|
+
* Configure the `<meta>` tag of the HTML.
|
|
1336
|
+
*
|
|
1337
|
+
* @default
|
|
1338
|
+
* ```js
|
|
1339
|
+
* const defaultMeta = {
|
|
1340
|
+
* charset: { charset: 'utf-8' },
|
|
1341
|
+
* viewport: 'width=device-width, initial-scale=1.0',
|
|
1342
|
+
* };
|
|
1343
|
+
* ```
|
|
1344
|
+
*/ meta?: ChainedHtmlOption<MetaOptions>;
|
|
1345
|
+
/**
|
|
1346
|
+
* Set the title tag of the HTML page.
|
|
1347
|
+
* @default 'Rsbuild App'
|
|
1348
|
+
*/ title?: ChainedHtmlOption<string>;
|
|
1349
|
+
/**
|
|
1350
|
+
* Set the inject position of the `<script>` tag.
|
|
1351
|
+
* @default 'head'
|
|
1352
|
+
*/ inject?: ChainedHtmlOption<ScriptInject>;
|
|
1353
|
+
/**
|
|
1354
|
+
* Inject custom html tags into the output html files.
|
|
1355
|
+
* @default undefined
|
|
1356
|
+
*/ tags?: OneOrMany<HtmlTagDescriptor>;
|
|
1357
|
+
/**
|
|
1358
|
+
* Set the favicon icon for all pages.
|
|
1359
|
+
* @default undefined
|
|
1360
|
+
*/ favicon?: ChainedHtmlOption<string>;
|
|
1361
|
+
/**
|
|
1362
|
+
* Set the web application icons to display when added to the home screen of a mobile device.
|
|
1363
|
+
*
|
|
1364
|
+
* @default undefined
|
|
1365
|
+
* @example
|
|
1366
|
+
* appIcon: {
|
|
1367
|
+
* name: 'My Website',
|
|
1368
|
+
* icons: [
|
|
1369
|
+
* { src: './icon-192.png', size: 192 },
|
|
1370
|
+
* { src: './icon-512.png', size: 512 },
|
|
1371
|
+
* ]
|
|
1372
|
+
* }
|
|
1373
|
+
*/ appIcon?: AppIcon;
|
|
1374
|
+
/**
|
|
1375
|
+
* Set the id of root element.
|
|
1376
|
+
* @default 'root'
|
|
1377
|
+
*/ mountId?: string;
|
|
1378
|
+
/**
|
|
1379
|
+
* Set the [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) attribute
|
|
1380
|
+
* of the `<script>` tag.
|
|
1381
|
+
* @default false
|
|
1382
|
+
*/ crossorigin?: boolean | CrossOrigin;
|
|
1383
|
+
/**
|
|
1384
|
+
* Define the directory structure of the HTML output files.
|
|
1385
|
+
* @default 'flat'
|
|
1386
|
+
*/ outputStructure?: OutputStructure;
|
|
1387
|
+
/**
|
|
1388
|
+
* Define the path to the HTML template,
|
|
1389
|
+
* corresponding to the `template` config of [html-rspack-plugin](https://github.com/rstackjs/html-rspack-plugin).
|
|
1390
|
+
* @default A built-in HTML template
|
|
1391
|
+
*/ template?: ChainedHtmlOption<string>;
|
|
1392
|
+
/**
|
|
1393
|
+
* Define the parameters in the HTML template,
|
|
1394
|
+
* corresponding to the `templateParameters` config of [html-rspack-plugin](https://github.com/rstackjs/html-rspack-plugin).
|
|
1395
|
+
*/ templateParameters?: ConfigChainAsyncWithContext<Record<string, unknown>, {
|
|
1396
|
+
entryName: string;
|
|
1397
|
+
}>;
|
|
1398
|
+
/**
|
|
1399
|
+
* Specifies how `<script>` tags generated by Rsbuild are loaded.
|
|
1400
|
+
* - `'defer'`: Adds the `defer` attribute so scripts load in parallel and run after
|
|
1401
|
+
* the document has been parsed.
|
|
1402
|
+
* - `'module'`: Adds `type="module"` to enable ES modules semantics.
|
|
1403
|
+
* - `'blocking'`: No `defer` or `async`, scripts execute immediately in order.
|
|
1404
|
+
* @default 'defer'. If `output.module` is enabled, the value is always `'module'`.
|
|
1405
|
+
*/ scriptLoading?: ScriptLoading;
|
|
1406
|
+
/**
|
|
1407
|
+
* Specifies which implementation to use for generating HTML files.
|
|
1408
|
+
*
|
|
1409
|
+
* - `'js'` (default) - Use the JavaScript-based `html-rspack-plugin`.
|
|
1410
|
+
* - `'native'` - Use Rspack's built-in `HtmlRspackPlugin` implemented in Rust.
|
|
1411
|
+
*
|
|
1412
|
+
* This option is experimental and may affect the available options in `tools.htmlPlugin`,
|
|
1413
|
+
* since the two implementations are not fully compatible.
|
|
1414
|
+
*
|
|
1415
|
+
* @default 'js'
|
|
1416
|
+
* @experimental
|
|
1417
|
+
*/ implementation?: HtmlImplementation;
|
|
1418
|
+
}
|
|
1419
|
+
export type NormalizedHtmlConfig = HtmlConfig & {
|
|
1420
|
+
meta: ChainedHtmlOption<MetaOptions>;
|
|
1421
|
+
title: ChainedHtmlOption<string>;
|
|
1422
|
+
mountId: string;
|
|
1423
|
+
inject: ChainedHtmlOption<ScriptInject>;
|
|
1424
|
+
crossorigin: boolean | CrossOrigin;
|
|
1425
|
+
outputStructure: OutputStructure;
|
|
1426
|
+
scriptLoading: ScriptLoading;
|
|
1427
|
+
implementation: HtmlImplementation;
|
|
1428
|
+
};
|
|
1429
|
+
export type ProgressBarConfig = {
|
|
1430
|
+
id?: string;
|
|
1431
|
+
};
|
|
1432
|
+
export type RequestHandler = Connect.NextHandleFunction;
|
|
1433
|
+
export type EnvironmentAPI = Record<string, {
|
|
1434
|
+
/**
|
|
1435
|
+
* Get stats info about current environment.
|
|
1436
|
+
*/ getStats: () => Promise<Rspack.Stats>;
|
|
1437
|
+
/**
|
|
1438
|
+
* Load and execute stats bundle in Server.
|
|
1439
|
+
*
|
|
1440
|
+
* @param entryName - relate to rsbuild source.entry
|
|
1441
|
+
* @returns the return of entry module.
|
|
1442
|
+
*/ loadBundle: <T = unknown>(entryName: string) => Promise<T>;
|
|
1443
|
+
/**
|
|
1444
|
+
* Get the compiled HTML template.
|
|
1445
|
+
*/ getTransformedHtml: (entryName: string) => Promise<string>;
|
|
1446
|
+
/**
|
|
1447
|
+
* HMR communication for the current environment.
|
|
1448
|
+
*/ hot: {
|
|
1449
|
+
send: HotSend;
|
|
1450
|
+
/**
|
|
1451
|
+
* Listen for accepted HMR connections in this environment.
|
|
1452
|
+
* Returns a function that removes the listener.
|
|
1453
|
+
*/ onConnect: HotOnConnect;
|
|
1454
|
+
};
|
|
1455
|
+
/**
|
|
1456
|
+
* Provides some context information about the current environment
|
|
1457
|
+
*/ context: EnvironmentContext;
|
|
1458
|
+
}>;
|
|
1459
|
+
export type SetupMiddlewaresContext = Pick<RsbuildDevServer, 'sockWrite' | 'environments'>;
|
|
1460
|
+
export type SetupMiddlewaresFn = (middlewares: {
|
|
1461
|
+
unshift: (...handlers: RequestHandler[]) => void;
|
|
1462
|
+
push: (...handlers: RequestHandler[]) => void;
|
|
1463
|
+
}, server: SetupMiddlewaresContext) => void;
|
|
1464
|
+
export type OverlayOptions = {
|
|
1465
|
+
/**
|
|
1466
|
+
* Whether to show build errors in the overlay. You can pass a filter
|
|
1467
|
+
* function to control which formatted build errors are rendered.
|
|
1468
|
+
* Return false from the filter function to hide a specific error.
|
|
1469
|
+
* @default true
|
|
1470
|
+
*/ errors?: boolean | ((error: Error) => boolean);
|
|
1471
|
+
/**
|
|
1472
|
+
* Whether to show runtime errors in the overlay. You can pass a filter
|
|
1473
|
+
* function to control which runtime errors are rendered.
|
|
1474
|
+
* Return false from the filter function to hide a specific error.
|
|
1475
|
+
* @default false
|
|
1476
|
+
*/ runtime?: boolean | ((error: Error) => boolean);
|
|
1477
|
+
};
|
|
1478
|
+
export type ClientConfig = {
|
|
1479
|
+
/**
|
|
1480
|
+
* The path for the WebSocket request.
|
|
1481
|
+
* @default '/rsbuild-hmr'
|
|
1482
|
+
*/ path?: string;
|
|
1483
|
+
/**
|
|
1484
|
+
* The port number for the WebSocket request.
|
|
1485
|
+
* @default location.port
|
|
1486
|
+
*/ port?: string | number;
|
|
1487
|
+
/**
|
|
1488
|
+
* The host for the WebSocket request.
|
|
1489
|
+
* @default location.hostname
|
|
1490
|
+
*/ host?: string;
|
|
1491
|
+
/**
|
|
1492
|
+
* The protocol name for the WebSocket request.
|
|
1493
|
+
* @default location.protocol === 'https:' ? 'wss' : 'ws'
|
|
1494
|
+
*/ protocol?: 'ws' | 'wss';
|
|
1495
|
+
/**
|
|
1496
|
+
* The maximum number of reconnection attempts after a WebSocket request is disconnected.
|
|
1497
|
+
* @default 100
|
|
1498
|
+
*/ reconnect?: number;
|
|
1499
|
+
/**
|
|
1500
|
+
* Whether to display an error overlay in the browser.
|
|
1501
|
+
* @default true
|
|
1502
|
+
*/ overlay?: boolean | OverlayOptions;
|
|
1503
|
+
/**
|
|
1504
|
+
* Controls the log level for client-side logging in the browser console.
|
|
1505
|
+
* @default 'info'
|
|
1506
|
+
*/ logLevel?: 'info' | 'warn' | 'error' | 'silent';
|
|
1507
|
+
/**
|
|
1508
|
+
* The path to a browser-side module that resolves the WebSocket URL.
|
|
1509
|
+
* The module should default export a function: `(url: string) => string`.
|
|
1510
|
+
*/ webSocketUrlResolver?: string;
|
|
1511
|
+
};
|
|
1512
|
+
export type NormalizedClientConfig = Optional<Required<ClientConfig>, 'protocol' | 'webSocketUrlResolver'>;
|
|
1513
|
+
export type WebSocketUrlResolver = (url: string) => string;
|
|
1514
|
+
export type { ChokidarOptions };
|
|
1515
|
+
export type WatchFiles = {
|
|
1516
|
+
/**
|
|
1517
|
+
* Paths of the files or directories to watch, supports glob syntax.
|
|
1518
|
+
*/ paths: string | string[];
|
|
1519
|
+
/**
|
|
1520
|
+
* File events that trigger the configured action.
|
|
1521
|
+
* - `add`: A file is created.
|
|
1522
|
+
* - `change`: A file is modified.
|
|
1523
|
+
* - `unlink`: A file is deleted.
|
|
1524
|
+
* @default ['add', 'change', 'unlink']
|
|
1525
|
+
*/ events?: WatchFileEvent[];
|
|
1526
|
+
/**
|
|
1527
|
+
* Watch options passed to [chokidar](https://github.com/paulmillr/chokidar).
|
|
1528
|
+
*/ options?: ChokidarOptions;
|
|
1529
|
+
/**
|
|
1530
|
+
* Specifies the action to take when files change.
|
|
1531
|
+
* - `reload-page`: Reload the page.
|
|
1532
|
+
* - `restart`: Trigger a restart request for the dev server or watch build.
|
|
1533
|
+
* - `reload-server`: Deprecated alias for `restart`.
|
|
1534
|
+
* @default 'reload-page'
|
|
1535
|
+
*/ type?: 'reload-page' | 'restart' | 'reload-server';
|
|
1536
|
+
};
|
|
1537
|
+
export type CliShortcut = {
|
|
1538
|
+
/**
|
|
1539
|
+
* The key to trigger the shortcut.
|
|
1540
|
+
*/ key: string;
|
|
1541
|
+
/**
|
|
1542
|
+
* The description of the shortcut.
|
|
1543
|
+
*/ description: string;
|
|
1544
|
+
/**
|
|
1545
|
+
* The action to execute when the shortcut is triggered.
|
|
1546
|
+
*/ action: () => void | Promise<void>;
|
|
1547
|
+
};
|
|
1548
|
+
export type WriteToDisk = boolean | ((filename: string) => boolean);
|
|
1549
|
+
export type BrowserLogsStackTrace = 'summary' | 'full' | 'none';
|
|
1550
|
+
export type LiveReload = boolean | {
|
|
1551
|
+
/**
|
|
1552
|
+
* Whether to trigger a full page reload when the HTML template changes.
|
|
1553
|
+
* @default true
|
|
1554
|
+
*/ html?: boolean;
|
|
1555
|
+
};
|
|
1556
|
+
export interface DevConfig {
|
|
1557
|
+
/**
|
|
1558
|
+
* Controls whether to forward browser runtime errors to the terminal. When `true`, the dev
|
|
1559
|
+
* client listens for `window.error` events and unhandled Promise rejections in the browser,
|
|
1560
|
+
* then sends them to the dev server where they are printed in the terminal (prefixed with
|
|
1561
|
+
* `[browser]`).
|
|
1562
|
+
* @default { stackTrace: 'summary' }
|
|
1563
|
+
*/ browserLogs?: boolean | {
|
|
1564
|
+
/**
|
|
1565
|
+
* Controls how the error stack trace is displayed in the terminal when forwarding
|
|
1566
|
+
* browser errors.
|
|
1567
|
+
* - `'summary'` – Show only the first frame (e.g. `(src/App.jsx:3:0)`).
|
|
1568
|
+
* - `'full'` – Print the full stack trace with all frames.
|
|
1569
|
+
* - `'none'` – Hide stack traces.
|
|
1570
|
+
* @default 'summary'
|
|
1571
|
+
*/ stackTrace?: BrowserLogsStackTrace;
|
|
1572
|
+
};
|
|
1573
|
+
/**
|
|
1574
|
+
* Whether to enable Hot Module Replacement.
|
|
1575
|
+
* @default true
|
|
1576
|
+
*/ hmr?: boolean;
|
|
1577
|
+
/**
|
|
1578
|
+
* Whether to reload the page when file changes are detected.
|
|
1579
|
+
* @default true
|
|
1580
|
+
*/ liveReload?: LiveReload;
|
|
1581
|
+
/**
|
|
1582
|
+
* Set the URL prefix of static assets in development mode,
|
|
1583
|
+
* similar to the [output.publicPath](https://rspack.rs/config/output#outputpublicpath)
|
|
1584
|
+
* config of Rspack.
|
|
1585
|
+
* @default `server.base`
|
|
1586
|
+
*/ assetPrefix?: LiteralUnion<'auto', string> | boolean;
|
|
1587
|
+
/**
|
|
1588
|
+
* Whether to render progress bars to display the build progress.
|
|
1589
|
+
* @default false
|
|
1590
|
+
*/ progressBar?: boolean | ProgressBarConfig;
|
|
1591
|
+
/**
|
|
1592
|
+
* Config for Rsbuild client code.
|
|
1593
|
+
*/ client?: ClientConfig;
|
|
1594
|
+
/**
|
|
1595
|
+
* Whether to enable CLI shortcuts.
|
|
1596
|
+
* @default true when using Rsbuild CLI, otherwise false
|
|
1597
|
+
*/ cliShortcuts?: boolean | {
|
|
1598
|
+
/**
|
|
1599
|
+
* Customize the CLI shortcuts.
|
|
1600
|
+
* @param shortcuts - The default CLI shortcuts.
|
|
1601
|
+
* @returns - The customized CLI shortcuts.
|
|
1602
|
+
*/ custom?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
1603
|
+
/**
|
|
1604
|
+
* Whether to print the help hint when the server is started.
|
|
1605
|
+
* - `true`: Print the default help hint.
|
|
1606
|
+
* - `false`: Disable the help hint.
|
|
1607
|
+
* - `string`: Print a custom help hint.
|
|
1608
|
+
* @default true
|
|
1609
|
+
*/ help?: boolean | string;
|
|
1610
|
+
};
|
|
1611
|
+
/**
|
|
1612
|
+
* Used to add custom middleware to the dev server.
|
|
1613
|
+
* @deprecated Use `server.setup` instead
|
|
1614
|
+
* @default undefined
|
|
1615
|
+
*/ setupMiddlewares?: SetupMiddlewaresFn | SetupMiddlewaresFn[];
|
|
1616
|
+
/**
|
|
1617
|
+
* Controls whether the build output from development mode is written to disk.
|
|
1618
|
+
* @default false
|
|
1619
|
+
*/ writeToDisk?: WriteToDisk;
|
|
1620
|
+
/**
|
|
1621
|
+
* Watch specified files and directories for changes. When a file change is detected,
|
|
1622
|
+
* it can trigger a page reload or a restart request for the dev server or watch build.
|
|
1623
|
+
* @default undefined
|
|
1624
|
+
*/ watchFiles?: WatchFiles | WatchFiles[];
|
|
1625
|
+
/**
|
|
1626
|
+
* Enable lazy compilation (compilation on demand).
|
|
1627
|
+
* @default { imports: true, entries: false }
|
|
1628
|
+
*/ lazyCompilation?: boolean | Rspack.LazyCompilationOptions;
|
|
1629
|
+
}
|
|
1630
|
+
export type NormalizedDevConfig = Omit<DevConfig, 'watchFiles'> & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts' | 'browserLogs'>> & {
|
|
1631
|
+
watchFiles: WatchFiles[];
|
|
1632
|
+
client: NormalizedClientConfig;
|
|
1633
|
+
};
|
|
1634
|
+
export interface ResolveConfig {
|
|
1635
|
+
/**
|
|
1636
|
+
* Force Rsbuild to resolve the specified packages from project root,
|
|
1637
|
+
* which is useful for deduplicating packages and reducing the bundle size.
|
|
1638
|
+
*/ dedupe?: string[];
|
|
1639
|
+
/**
|
|
1640
|
+
* Set the alias for the module path, which is used to simplify the import path or
|
|
1641
|
+
* redirect the module reference.
|
|
1642
|
+
* Similar to the [resolve.alias](https://rspack.rs/config/resolve) config of Rspack.
|
|
1643
|
+
* @default { '@swc/helpers': path.dirname(require.resolve('@swc/helpers/package.json')) }
|
|
1644
|
+
*/ alias?: ConfigChain<Alias>;
|
|
1645
|
+
/**
|
|
1646
|
+
* Set the strategy for path alias resolution, to control the priority relationship
|
|
1647
|
+
* between the `paths` option in `tsconfig.json` and the `resolve.alias` option of Rsbuild.
|
|
1648
|
+
* - `prefer-tsconfig`: The `paths` option in `tsconfig.json` will take precedence over the
|
|
1649
|
+
* `resolve.alias` option of Rsbuild.
|
|
1650
|
+
* - `prefer-alias`: The `resolve.alias` option of Rsbuild will take precedence over the
|
|
1651
|
+
* `paths` option in `tsconfig.json`.
|
|
1652
|
+
* @default 'prefer-tsconfig'
|
|
1653
|
+
*/ aliasStrategy?: AliasStrategy;
|
|
1654
|
+
/**
|
|
1655
|
+
* Automatically resolve file extensions when importing modules.
|
|
1656
|
+
* This means you can import files without explicitly writing their extensions.
|
|
1657
|
+
* @default ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json']
|
|
1658
|
+
*/ extensions?: string[];
|
|
1659
|
+
/**
|
|
1660
|
+
* Specifies the condition names used to match entry points in the exports field
|
|
1661
|
+
* of a package.
|
|
1662
|
+
* @default Inherits from Rspack. See https://rspack.rs/config/resolve#resolveconditionnames
|
|
1663
|
+
*/ conditionNames?: string[];
|
|
1664
|
+
/**
|
|
1665
|
+
* Controls the priority of fields in a package.json used to locate a package's
|
|
1666
|
+
* entry file. It is the ordered list of package.json fields Rspack will try
|
|
1667
|
+
* when resolving an npm package's entry point.
|
|
1668
|
+
* @default
|
|
1669
|
+
* - If `output.target` is `'web'`, `'web-worker'`, or not specified, the default value is `["browser", "module", "main"]`.
|
|
1670
|
+
* - If `output.target` is `'node'`, the default value is `["module", "main"]`.
|
|
1671
|
+
*/ mainFields?: string[];
|
|
1672
|
+
}
|
|
1673
|
+
export type NormalizedResolveConfig = ResolveConfig & Pick<Required<ResolveConfig>, 'alias' | 'aliasStrategy' | 'extensions'>;
|
|
1674
|
+
export type ModuleFederationConfig = {
|
|
1675
|
+
options: ModuleFederationPluginOptions;
|
|
1676
|
+
};
|
|
1677
|
+
export type NormalizedModuleFederationConfig = ModuleFederationConfig;
|
|
1678
|
+
export type RsbuildConfigMeta = {
|
|
1679
|
+
/**
|
|
1680
|
+
* Path to the rsbuild config file.
|
|
1681
|
+
*/ configFilePath: string;
|
|
1682
|
+
/**
|
|
1683
|
+
* Paths to files imported by the rsbuild config file.
|
|
1684
|
+
*/ configFileDependencies?: string[];
|
|
1685
|
+
};
|
|
1686
|
+
/**
|
|
1687
|
+
* Only some dev options can be defined in the environment config
|
|
1688
|
+
*/ export type AllowedEnvironmentDevKeys = 'hmr' | 'client' | 'liveReload' | 'browserLogs' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk';
|
|
1689
|
+
/**
|
|
1690
|
+
* The Rsbuild config to run in the specified environment.
|
|
1691
|
+
*/ export interface EnvironmentConfig {
|
|
1692
|
+
/**
|
|
1693
|
+
* Options for local development.
|
|
1694
|
+
*/ dev?: Pick<DevConfig, AllowedEnvironmentDevKeys>;
|
|
1695
|
+
/**
|
|
1696
|
+
* Options for HTML generation.
|
|
1697
|
+
*/ html?: HtmlConfig;
|
|
1698
|
+
/**
|
|
1699
|
+
* Options for the low-level tools.
|
|
1700
|
+
*/ tools?: ToolsConfig;
|
|
1701
|
+
/**
|
|
1702
|
+
* Options for module resolution.
|
|
1703
|
+
*/ resolve?: ResolveConfig;
|
|
1704
|
+
/**
|
|
1705
|
+
* Options for input source code.
|
|
1706
|
+
*/ source?: SourceConfig;
|
|
1707
|
+
/**
|
|
1708
|
+
* Options for build outputs.
|
|
1709
|
+
*/ output?: OutputConfig;
|
|
1710
|
+
/**
|
|
1711
|
+
* Options for Web security.
|
|
1712
|
+
*/ security?: SecurityConfig;
|
|
1713
|
+
/**
|
|
1714
|
+
* Options for build performance and runtime performance.
|
|
1715
|
+
*/ performance?: PerformanceConfig;
|
|
1716
|
+
/**
|
|
1717
|
+
* Options for chunk splitting.
|
|
1718
|
+
*/ splitChunks?: SplitChunksConfig | false;
|
|
1719
|
+
/**
|
|
1720
|
+
* Options for module federation.
|
|
1721
|
+
*/ moduleFederation?: ModuleFederationConfig;
|
|
1722
|
+
/**
|
|
1723
|
+
* Configure Rsbuild plugins.
|
|
1724
|
+
*/ plugins?: RsbuildPlugins;
|
|
1725
|
+
}
|
|
1726
|
+
export type LogLevel = 'info' | 'warn' | 'error' | 'silent';
|
|
1727
|
+
/**
|
|
1728
|
+
* The Rsbuild config.
|
|
1729
|
+
*/ export interface RsbuildConfig extends EnvironmentConfig {
|
|
1730
|
+
/**
|
|
1731
|
+
* Specify the build mode for Rsbuild, as each mode has different default behavior and optimizations.
|
|
1732
|
+
* @default Depends on `process.env.NODE_ENV`:
|
|
1733
|
+
* - `'production'` if NODE_ENV is 'production'
|
|
1734
|
+
* - `'development'` if NODE_ENV is 'development'
|
|
1735
|
+
* - otherwise `'none'`
|
|
1736
|
+
*/ mode?: RsbuildMode;
|
|
1737
|
+
/**
|
|
1738
|
+
* Specify the project root directory. Can be an absolute path, or a path relative to `process.cwd()`.
|
|
1739
|
+
* @default `process.cwd()`
|
|
1740
|
+
*/ root?: string;
|
|
1741
|
+
/**
|
|
1742
|
+
* Specify the log level of Rsbuild.
|
|
1743
|
+
* - 'info': Output all logs.
|
|
1744
|
+
* - 'warn': Output `warn` and `error` level logs.
|
|
1745
|
+
* - 'error': Output `error` level logs.
|
|
1746
|
+
* - 'silent': Do not output any logs.
|
|
1747
|
+
* @default 'info'
|
|
1748
|
+
*/ logLevel?: LogLevel;
|
|
1749
|
+
/**
|
|
1750
|
+
* Use a custom logger instance for the current Rsbuild instance.
|
|
1751
|
+
* You can create one via `createLogger()`.
|
|
1752
|
+
*/ customLogger?: Logger;
|
|
1753
|
+
/**
|
|
1754
|
+
* Options for local development.
|
|
1755
|
+
*/ dev?: DevConfig;
|
|
1756
|
+
/**
|
|
1757
|
+
* Options for the Rsbuild server.
|
|
1758
|
+
* Mainly applies to local development and preview.
|
|
1759
|
+
* Some options (e.g. `publicDir`, `base`) also affect production builds.
|
|
1760
|
+
*/ server?: ServerConfig;
|
|
1761
|
+
/**
|
|
1762
|
+
* Configure Rsbuild config by environment.
|
|
1763
|
+
* The key represents the environment name.
|
|
1764
|
+
* The value is the Rsbuild config for the specified environment.
|
|
1765
|
+
*/ environments?: Record<string, EnvironmentConfig>;
|
|
1766
|
+
/**
|
|
1767
|
+
* @private
|
|
1768
|
+
*/ _privateMeta?: RsbuildConfigMeta;
|
|
1769
|
+
}
|
|
1770
|
+
export type MergedEnvironmentConfig = {
|
|
1771
|
+
mode: RsbuildMode;
|
|
1772
|
+
root: string;
|
|
1773
|
+
dev: Pick<NormalizedDevConfig, AllowedEnvironmentDevKeys>;
|
|
1774
|
+
html: NormalizedHtmlConfig;
|
|
1775
|
+
tools: NormalizedToolsConfig;
|
|
1776
|
+
resolve: NormalizedResolveConfig;
|
|
1777
|
+
source: NormalizedSourceConfig;
|
|
1778
|
+
output: Omit<NormalizedOutputConfig, 'distPath'> & {
|
|
1779
|
+
distPath: Optional<Required<DistPathConfig>, 'jsAsync' | 'cssAsync'>;
|
|
1780
|
+
};
|
|
1781
|
+
plugins?: RsbuildPlugins;
|
|
1782
|
+
security: NormalizedSecurityConfig;
|
|
1783
|
+
performance: NormalizedPerformanceConfig;
|
|
1784
|
+
splitChunks: NormalizedSplitChunksConfig | false;
|
|
1785
|
+
moduleFederation?: ModuleFederationConfig;
|
|
1786
|
+
};
|
|
1787
|
+
/**
|
|
1788
|
+
* The normalized Rsbuild environment config.
|
|
1789
|
+
*/ export type NormalizedEnvironmentConfig = TwoLevelReadonly<Omit<MergedEnvironmentConfig, 'dev'> & {
|
|
1790
|
+
dev: NormalizedDevConfig;
|
|
1791
|
+
server: NormalizedServerConfig;
|
|
1792
|
+
_privateMeta?: RsbuildConfigMeta;
|
|
1793
|
+
}>;
|
|
1794
|
+
export type NormalizedConfig = NormalizedEnvironmentConfig & {
|
|
1795
|
+
environments: Record<string, NormalizedEnvironmentConfig>;
|
|
1796
|
+
};
|