@ohos-ports/rsbuild-core 1.1.14-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +28 -0
- package/bin/rsbuild.js +20 -0
- package/compiled/chokidar/index.d.ts +345 -0
- package/compiled/chokidar/index.js +1778 -0
- package/compiled/chokidar/license +21 -0
- package/compiled/chokidar/package.json +1 -0
- package/compiled/connect/index.d.ts +90 -0
- package/compiled/connect/index.js +1240 -0
- package/compiled/connect/license +25 -0
- package/compiled/connect/package.json +1 -0
- package/compiled/connect-history-api-fallback/index.d.ts +1 -0
- package/compiled/connect-history-api-fallback/index.js +149 -0
- package/compiled/connect-history-api-fallback/license +21 -0
- package/compiled/connect-history-api-fallback/package.json +1 -0
- package/compiled/cors/index.d.ts +1 -0
- package/compiled/cors/index.js +371 -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 +8008 -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/index.d.ts +289 -0
- package/compiled/html-rspack-plugin/index.js +1583 -0
- package/compiled/html-rspack-plugin/license +20 -0
- package/compiled/html-rspack-plugin/loader.js +162 -0
- package/compiled/html-rspack-plugin/package.json +1 -0
- package/compiled/http-proxy-middleware/index.d.ts +318 -0
- package/compiled/http-proxy-middleware/index.js +5280 -0
- package/compiled/http-proxy-middleware/license +22 -0
- package/compiled/http-proxy-middleware/package.json +1 -0
- package/compiled/jiti/index.d.ts +1 -0
- package/compiled/jiti/index.js +416 -0
- package/compiled/jiti/license +21 -0
- package/compiled/jiti/package.json +1 -0
- package/compiled/launch-editor-middleware/index.d.ts +1 -0
- package/compiled/launch-editor-middleware/index.js +694 -0
- package/compiled/launch-editor-middleware/license +21 -0
- package/compiled/launch-editor-middleware/package.json +1 -0
- package/compiled/mrmime/index.d.ts +4 -0
- package/compiled/mrmime/index.js +452 -0
- package/compiled/mrmime/package.json +1 -0
- package/compiled/on-finished/index.d.ts +13 -0
- package/compiled/on-finished/index.js +197 -0
- package/compiled/on-finished/license +23 -0
- package/compiled/on-finished/package.json +1 -0
- package/compiled/open/index.d.ts +153 -0
- package/compiled/open/index.js +409 -0
- package/compiled/open/package.json +1 -0
- package/compiled/open/xdg-open +1066 -0
- package/compiled/picocolors/index.d.ts +55 -0
- package/compiled/picocolors/index.js +108 -0
- package/compiled/picocolors/license +15 -0
- package/compiled/picocolors/package.json +1 -0
- package/compiled/postcss/index.d.ts +1 -0
- package/compiled/postcss/index.js +5997 -0
- package/compiled/postcss/license +20 -0
- package/compiled/postcss/package.json +1 -0
- package/compiled/postcss-load-config/index.d.ts +1 -0
- package/compiled/postcss-load-config/index.js +739 -0
- package/compiled/postcss-load-config/license +20 -0
- package/compiled/postcss-load-config/package.json +1 -0
- package/compiled/postcss-loader/index.d.ts +1 -0
- package/compiled/postcss-loader/index.js +741 -0
- package/compiled/postcss-loader/license +20 -0
- package/compiled/postcss-loader/package.json +1 -0
- package/compiled/rsbuild-dev-middleware/index.d.ts +1 -0
- package/compiled/rsbuild-dev-middleware/index.js +6158 -0
- package/compiled/rsbuild-dev-middleware/license +20 -0
- package/compiled/rsbuild-dev-middleware/package.json +1 -0
- package/compiled/rslog/index.d.ts +66 -0
- package/compiled/rslog/index.js +334 -0
- package/compiled/rslog/license +21 -0
- package/compiled/rslog/package.json +1 -0
- package/compiled/rspack-chain/index.d.ts +611 -0
- package/compiled/rspack-chain/index.js +1740 -0
- package/compiled/rspack-chain/license +373 -0
- package/compiled/rspack-chain/package.json +1 -0
- package/compiled/rspack-manifest-plugin/index.d.ts +44 -0
- package/compiled/rspack-manifest-plugin/index.js +394 -0
- package/compiled/rspack-manifest-plugin/license +21 -0
- package/compiled/rspack-manifest-plugin/package.json +1 -0
- package/compiled/sirv/index.d.ts +1 -0
- package/compiled/sirv/index.js +709 -0
- package/compiled/sirv/package.json +1 -0
- package/compiled/style-loader/index.d.ts +1 -0
- package/compiled/style-loader/index.js +427 -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/tinyglobby/index.d.ts +25 -0
- package/compiled/tinyglobby/index.js +2749 -0
- package/compiled/tinyglobby/index1.js +17 -0
- package/compiled/tinyglobby/license +21 -0
- package/compiled/tinyglobby/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/index.d.ts +160 -0
- package/compiled/webpack-bundle-analyzer/index.js +13480 -0
- package/compiled/webpack-bundle-analyzer/license +20 -0
- package/compiled/webpack-bundle-analyzer/package.json +1 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js +16 -0
- package/compiled/webpack-bundle-analyzer/public/viewer.js.LICENSE.txt +10 -0
- package/compiled/webpack-merge/index.d.ts +31 -0
- package/compiled/webpack-merge/index.js +1200 -0
- package/compiled/webpack-merge/license +20 -0
- package/compiled/webpack-merge/package.json +1 -0
- package/compiled/ws/index.d.ts +401 -0
- package/compiled/ws/index.js +3153 -0
- package/compiled/ws/license +20 -0
- package/compiled/ws/package.json +1 -0
- package/dist/client/hmr.js +143 -0
- package/dist/client/overlay.js +210 -0
- package/dist/ignoreCssLoader.mjs +4 -0
- package/dist/index.cjs +7251 -0
- package/dist/index.js +7118 -0
- package/dist/transformLoader.mjs +22 -0
- package/dist/transformRawLoader.mjs +22 -0
- package/dist-types/cli/commands.d.ts +23 -0
- package/dist-types/cli/index.d.ts +1 -0
- package/dist-types/cli/init.d.ts +7 -0
- package/dist-types/cli/prepare.d.ts +1 -0
- package/dist-types/client/hmr.d.ts +1 -0
- package/dist-types/client/overlay.d.ts +1 -0
- package/dist-types/config.d.ts +90 -0
- package/dist-types/configChain.d.ts +139 -0
- package/dist-types/constants.d.ts +37 -0
- package/dist-types/createContext.d.ts +11 -0
- package/dist-types/createRsbuild.d.ts +2 -0
- package/dist-types/helpers/format.d.ts +5 -0
- package/dist-types/helpers/fs.d.ts +13 -0
- package/dist-types/helpers/index.d.ts +47 -0
- package/dist-types/helpers/path.d.ts +11 -0
- package/dist-types/helpers/stats.d.ts +9 -0
- package/dist-types/hooks.d.ts +48 -0
- package/dist-types/index.d.ts +26 -0
- package/dist-types/initPlugins.d.ts +6 -0
- package/dist-types/internal.d.ts +6 -0
- package/dist-types/loadEnv.d.ts +50 -0
- package/dist-types/loader/ignoreCssLoader.d.ts +2 -0
- package/dist-types/loader/transformLoader.d.ts +7 -0
- package/dist-types/loader/transformRawLoader.d.ts +3 -0
- package/dist-types/logger.d.ts +4 -0
- package/dist-types/mergeConfig.d.ts +2 -0
- package/dist-types/package.json +1 -0
- package/dist-types/pluginHelper.d.ts +12 -0
- package/dist-types/pluginManager.d.ts +9 -0
- package/dist-types/plugins/appIcon.d.ts +2 -0
- package/dist-types/plugins/asset.d.ts +3 -0
- package/dist-types/plugins/basic.d.ts +5 -0
- package/dist-types/plugins/bundleAnalyzer.d.ts +2 -0
- package/dist-types/plugins/cache.d.ts +2 -0
- package/dist-types/plugins/cleanOutput.d.ts +3 -0
- package/dist-types/plugins/css.d.ts +3 -0
- package/dist-types/plugins/define.d.ts +2 -0
- package/dist-types/plugins/entry.d.ts +2 -0
- package/dist-types/plugins/externals.d.ts +2 -0
- package/dist-types/plugins/fileSize.d.ts +4 -0
- package/dist-types/plugins/html.d.ts +9 -0
- package/dist-types/plugins/inlineChunk.d.ts +2 -0
- package/dist-types/plugins/lazyCompilation.d.ts +2 -0
- package/dist-types/plugins/manifest.d.ts +2 -0
- package/dist-types/plugins/minimize.d.ts +10 -0
- package/dist-types/plugins/moduleFederation.d.ts +2 -0
- package/dist-types/plugins/moment.d.ts +2 -0
- package/dist-types/plugins/nodeAddons.d.ts +2 -0
- package/dist-types/plugins/nonce.d.ts +2 -0
- package/dist-types/plugins/output.d.ts +2 -0
- package/dist-types/plugins/performance.d.ts +5 -0
- package/dist-types/plugins/progress.d.ts +2 -0
- package/dist-types/plugins/resolve.d.ts +2 -0
- package/dist-types/plugins/resourceHints.d.ts +2 -0
- package/dist-types/plugins/rsdoctor.d.ts +2 -0
- package/dist-types/plugins/rspackProfile.d.ts +2 -0
- package/dist-types/plugins/server.d.ts +2 -0
- package/dist-types/plugins/splitChunks.d.ts +4 -0
- package/dist-types/plugins/sri.d.ts +2 -0
- package/dist-types/plugins/swc.d.ts +7 -0
- package/dist-types/plugins/target.d.ts +2 -0
- package/dist-types/plugins/wasm.d.ts +2 -0
- package/dist-types/provider/build.d.ts +3 -0
- package/dist-types/provider/createCompiler.d.ts +27 -0
- package/dist-types/provider/helpers.d.ts +12 -0
- package/dist-types/provider/initConfigs.d.ts +10 -0
- package/dist-types/provider/inspectConfig.d.ts +6 -0
- package/dist-types/provider/provider.d.ts +2 -0
- package/dist-types/provider/rspackConfig.d.ts +8 -0
- package/dist-types/rspack/RsbuildHtmlPlugin.d.ts +37 -0
- package/dist-types/rspack/preload/HtmlPreloadOrPrefetchPlugin.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/determineAsValue.d.ts +22 -0
- package/dist-types/rspack/preload/helpers/doesChunkBelongToHtml.d.ts +29 -0
- package/dist-types/rspack/preload/helpers/extractChunks.d.ts +28 -0
- package/dist-types/rspack/preload/helpers/index.d.ts +4 -0
- package/dist-types/rspack/preload/helpers/type.d.ts +13 -0
- package/dist-types/server/ansiHTML.d.ts +12 -0
- package/dist-types/server/cliShortcuts.d.ts +10 -0
- package/dist-types/server/compilerDevMiddleware.d.ts +31 -0
- package/dist-types/server/devMiddleware.d.ts +27 -0
- package/dist-types/server/devServer.d.ts +60 -0
- package/dist-types/server/environment.d.ts +8 -0
- package/dist-types/server/getDevMiddlewares.d.ts +25 -0
- package/dist-types/server/gzipMiddleware.d.ts +4 -0
- package/dist-types/server/helper.d.ts +71 -0
- package/dist-types/server/httpServer.d.ts +8 -0
- package/dist-types/server/middlewares.d.ts +34 -0
- package/dist-types/server/open.d.ts +10 -0
- package/dist-types/server/prodServer.d.ts +25 -0
- package/dist-types/server/proxy.d.ts +6 -0
- package/dist-types/server/restart.d.ts +14 -0
- package/dist-types/server/runner/asModule.d.ts +2 -0
- package/dist-types/server/runner/basic.d.ts +25 -0
- package/dist-types/server/runner/cjs.d.ts +10 -0
- package/dist-types/server/runner/esm.d.ts +6 -0
- package/dist-types/server/runner/index.d.ts +8 -0
- package/dist-types/server/runner/type.d.ts +36 -0
- package/dist-types/server/socketServer.d.ts +26 -0
- package/dist-types/server/watchFiles.d.ts +14 -0
- package/dist-types/types/config.d.ts +1309 -0
- package/dist-types/types/context.d.ts +52 -0
- package/dist-types/types/hooks.d.ts +146 -0
- package/dist-types/types/index.d.ts +8 -0
- package/dist-types/types/plugin.d.ts +329 -0
- package/dist-types/types/rsbuild.d.ts +156 -0
- package/dist-types/types/rspack.d.ts +16 -0
- package/dist-types/types/thirdParty.d.ts +176 -0
- package/dist-types/types/utils.d.ts +12 -0
- package/package.json +61 -0
- package/static/openChrome.applescript +95 -0
- package/types.d.ts +221 -0
|
@@ -0,0 +1,1309 @@
|
|
|
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 { Configuration, CopyRspackPluginOptions, Externals, LightningCssMinimizerRspackPluginOptions, ModuleFederationPluginOptions, RuleSetCondition, SwcJsMinimizerRspackPluginOptions, SwcLoaderOptions, rspack } from '@rspack/core';
|
|
5
|
+
import type { ChokidarOptions } from '../../compiled/chokidar/index.js';
|
|
6
|
+
import type cors from '../../compiled/cors/index.js';
|
|
7
|
+
import type { Options as HttpProxyOptions, Filter as ProxyFilter } from '../../compiled/http-proxy-middleware/index.js';
|
|
8
|
+
import type RspackChain from '../../compiled/rspack-chain/index.js';
|
|
9
|
+
import type { BundleAnalyzerPlugin } from '../../compiled/webpack-bundle-analyzer/index.js';
|
|
10
|
+
import type { ModifyBundlerChainUtils, ModifyChainUtils, Routes } from './hooks';
|
|
11
|
+
import type { ModifyWebpackChainUtils, ModifyWebpackConfigUtils, RsbuildPlugins } from './plugin';
|
|
12
|
+
import type { RsbuildEntry, RsbuildMode, RsbuildTarget } from './rsbuild';
|
|
13
|
+
import type { BundlerPluginInstance, Rspack, RspackRule } from './rspack';
|
|
14
|
+
import type { CSSExtractOptions, CSSLoaderModulesOptions, CSSLoaderOptions, HtmlRspackPlugin, PostCSSLoaderOptions, PostCSSPlugin, StyleLoaderOptions, WebpackConfig } from './thirdParty';
|
|
15
|
+
import type { ConfigChain, ConfigChainAsyncWithContext, ConfigChainMergeContext, ConfigChainWithContext, DeepReadonly, MaybePromise, OneOrMany } from './utils';
|
|
16
|
+
export type ToolsSwcConfig = ConfigChain<SwcLoaderOptions>;
|
|
17
|
+
export type ToolsBundlerChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyBundlerChainUtils) => MaybePromise<void>>;
|
|
18
|
+
export type ToolsPostCSSLoaderConfig = ConfigChainWithContext<PostCSSLoaderOptions, {
|
|
19
|
+
addPlugins: (plugins: PostCSSPlugin | PostCSSPlugin[]) => void;
|
|
20
|
+
}>;
|
|
21
|
+
export type ToolsCSSLoaderConfig = ConfigChain<CSSLoaderOptions>;
|
|
22
|
+
export type ToolsStyleLoaderConfig = ConfigChain<StyleLoaderOptions>;
|
|
23
|
+
export type ToolsHtmlPluginConfig = ConfigChainWithContext<HtmlRspackPlugin.Options, {
|
|
24
|
+
entryName: string;
|
|
25
|
+
entryValue: (string | string[] | Rspack.EntryDescription)[];
|
|
26
|
+
}>;
|
|
27
|
+
export type ModifyRspackConfigUtils = ModifyChainUtils & {
|
|
28
|
+
addRules: (rules: RspackRule | RspackRule[]) => void;
|
|
29
|
+
appendRules: (rules: RspackRule | RspackRule[]) => void;
|
|
30
|
+
prependPlugins: (plugins: BundlerPluginInstance | BundlerPluginInstance[]) => void;
|
|
31
|
+
appendPlugins: (plugins: BundlerPluginInstance | BundlerPluginInstance[]) => void;
|
|
32
|
+
removePlugin: (pluginName: string) => void;
|
|
33
|
+
mergeConfig: typeof import('../../compiled/webpack-merge/index.js').merge;
|
|
34
|
+
rspack: typeof rspack;
|
|
35
|
+
};
|
|
36
|
+
export type ToolsRspackConfig = ConfigChainAsyncWithContext<Rspack.Configuration, ModifyRspackConfigUtils>;
|
|
37
|
+
export type ToolsWebpackConfig = ConfigChainWithContext<WebpackConfig, ModifyWebpackConfigUtils>;
|
|
38
|
+
export type ToolsWebpackChainConfig = OneOrMany<(chain: RspackChain, utils: ModifyWebpackChainUtils) => void>;
|
|
39
|
+
export interface ToolsConfig {
|
|
40
|
+
/**
|
|
41
|
+
* Configure bundler config base on [rspack-chain](https://github.com/rspack-contrib/rspack-chain)
|
|
42
|
+
*/
|
|
43
|
+
bundlerChain?: ToolsBundlerChainConfig;
|
|
44
|
+
/**
|
|
45
|
+
* Modify the options of [css-loader](https://github.com/webpack-contrib/css-loader).
|
|
46
|
+
*/
|
|
47
|
+
cssLoader?: ToolsCSSLoaderConfig;
|
|
48
|
+
/**
|
|
49
|
+
* Modify the options of [postcss-loader](https://github.com/webpack-contrib/postcss-loader).
|
|
50
|
+
*/
|
|
51
|
+
postcss?: ToolsPostCSSLoaderConfig;
|
|
52
|
+
/**
|
|
53
|
+
* Modify the options of [style-loader](https://github.com/webpack-contrib/style-loader).
|
|
54
|
+
*/
|
|
55
|
+
styleLoader?: ToolsStyleLoaderConfig;
|
|
56
|
+
/**
|
|
57
|
+
* Configure the html-rspack-plugin.
|
|
58
|
+
*/
|
|
59
|
+
htmlPlugin?: boolean | ToolsHtmlPluginConfig;
|
|
60
|
+
/**
|
|
61
|
+
* Configure the `builtin:swc-loader` of Rspack.
|
|
62
|
+
*/
|
|
63
|
+
swc?: ToolsSwcConfig;
|
|
64
|
+
/**
|
|
65
|
+
* Configure the `builtin:lightningcss-loader` of Rspack.
|
|
66
|
+
*/
|
|
67
|
+
lightningcssLoader?: boolean | ConfigChain<Rspack.LightningcssLoaderOptions>;
|
|
68
|
+
/**
|
|
69
|
+
* Modify the options of [CssExtractRspackPlugin](https://rspack.dev/plugins/rspack/css-extract-rspack-plugin).
|
|
70
|
+
*/
|
|
71
|
+
cssExtract?: CSSExtractOptions;
|
|
72
|
+
/**
|
|
73
|
+
* Configure Rspack.
|
|
74
|
+
*/
|
|
75
|
+
rspack?: ToolsRspackConfig;
|
|
76
|
+
/**
|
|
77
|
+
* Configure [webpack](https://webpack.js.org/).
|
|
78
|
+
* @requires webpack
|
|
79
|
+
*/
|
|
80
|
+
webpack?: ToolsWebpackConfig;
|
|
81
|
+
/**
|
|
82
|
+
* Configure webpack by [rspack-chain](https://github.com/rspack-contrib/rspack-chain).
|
|
83
|
+
* @requires webpack
|
|
84
|
+
*/
|
|
85
|
+
webpackChain?: ToolsWebpackChainConfig;
|
|
86
|
+
}
|
|
87
|
+
export type NormalizedToolsConfig = ToolsConfig & {
|
|
88
|
+
cssExtract: Required<CSSExtractOptions>;
|
|
89
|
+
};
|
|
90
|
+
export type Alias = Record<string, string | false | (string | false)[]>;
|
|
91
|
+
export type Define = Record<string, any>;
|
|
92
|
+
export type AliasStrategy = 'prefer-tsconfig' | 'prefer-alias';
|
|
93
|
+
export type Decorators = {
|
|
94
|
+
/**
|
|
95
|
+
* Specify the version of decorators to use.
|
|
96
|
+
* @default '2022-03'
|
|
97
|
+
*/
|
|
98
|
+
version?: 'legacy' | '2022-03';
|
|
99
|
+
};
|
|
100
|
+
export interface SourceConfig {
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Use `resolve.alias` instead.
|
|
103
|
+
* `source.alias` will be removed in v2.0.0.
|
|
104
|
+
*/
|
|
105
|
+
alias?: ConfigChain<Alias>;
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated Use `resolve.aliasStrategy` instead.
|
|
108
|
+
* `source.aliasStrategy` will be removed in v2.0.0.
|
|
109
|
+
*/
|
|
110
|
+
aliasStrategy?: AliasStrategy;
|
|
111
|
+
/**
|
|
112
|
+
* Include additional files that should be treated as static assets.
|
|
113
|
+
* @default undefined
|
|
114
|
+
*/
|
|
115
|
+
assetsInclude?: Rspack.RuleSetCondition;
|
|
116
|
+
/**
|
|
117
|
+
* Specify directories or modules that need additional compilation.
|
|
118
|
+
* In order to maintain faster compilation speed, Rsbuild will not compile files under node_modules through
|
|
119
|
+
* `babel-loader` or `ts-loader` by default, as will as the files outside the current project directory.
|
|
120
|
+
*/
|
|
121
|
+
include?: RuleSetCondition[];
|
|
122
|
+
/**
|
|
123
|
+
* Set the entry modules.
|
|
124
|
+
*/
|
|
125
|
+
entry?: RsbuildEntry;
|
|
126
|
+
/**
|
|
127
|
+
* Specifies that certain files that will be excluded from compilation.
|
|
128
|
+
*/
|
|
129
|
+
exclude?: RuleSetCondition[];
|
|
130
|
+
/**
|
|
131
|
+
* Add a script before the entry file of each page.
|
|
132
|
+
* This script will be executed before the page code.
|
|
133
|
+
* It can be used to execute global logics, such as polyfill injection.
|
|
134
|
+
*/
|
|
135
|
+
preEntry?: string | string[];
|
|
136
|
+
/**
|
|
137
|
+
* Used to replaces variables in your code with other values or expressions at compile time.
|
|
138
|
+
*/
|
|
139
|
+
define?: Define;
|
|
140
|
+
/**
|
|
141
|
+
* Configuring decorators syntax.
|
|
142
|
+
*/
|
|
143
|
+
decorators?: Decorators;
|
|
144
|
+
/**
|
|
145
|
+
* Used to import the code and style of the component library on demand.
|
|
146
|
+
*/
|
|
147
|
+
transformImport?: TransformImportFn | Array<TransformImport | TransformImportFn>;
|
|
148
|
+
/**
|
|
149
|
+
* Configure a custom tsconfig.json file path to use, can be a relative or absolute path.
|
|
150
|
+
* @default 'tsconfig.json'
|
|
151
|
+
*/
|
|
152
|
+
tsconfigPath?: string;
|
|
153
|
+
}
|
|
154
|
+
export type TransformImport = {
|
|
155
|
+
libraryName: string;
|
|
156
|
+
libraryDirectory?: string;
|
|
157
|
+
style?: string | boolean;
|
|
158
|
+
styleLibraryDirectory?: string;
|
|
159
|
+
camelToDashComponentName?: boolean;
|
|
160
|
+
transformToDefaultImport?: boolean;
|
|
161
|
+
customName?: any;
|
|
162
|
+
customStyleName?: any;
|
|
163
|
+
};
|
|
164
|
+
type TransformImportFn = (imports: TransformImport[]) => TransformImport[] | void;
|
|
165
|
+
export interface NormalizedSourceConfig extends SourceConfig {
|
|
166
|
+
define: Define;
|
|
167
|
+
/**
|
|
168
|
+
* @deprecated Use `resolve.alias` instead.
|
|
169
|
+
* `source.alias` will be removed in v2.0.0.
|
|
170
|
+
*/
|
|
171
|
+
alias: ConfigChain<Alias>;
|
|
172
|
+
preEntry: string[];
|
|
173
|
+
decorators: Required<Decorators>;
|
|
174
|
+
}
|
|
175
|
+
export type HtmlFallback = false | 'index';
|
|
176
|
+
export type ProxyBypass = (req: IncomingMessage, res: ServerResponse, proxyOptions: ProxyOptions) => string | undefined | null | boolean;
|
|
177
|
+
export type ProxyOptions = HttpProxyOptions & {
|
|
178
|
+
/**
|
|
179
|
+
* Bypass the proxy based on the return value of a function.
|
|
180
|
+
* - Return `null` or `undefined` to continue processing the request with proxy.
|
|
181
|
+
* - Return `true` to continue processing the request without proxy.
|
|
182
|
+
* - Return `false` to produce a 404 error for the request.
|
|
183
|
+
* - Return a path to serve from, instead of continuing to proxy the request.
|
|
184
|
+
*/
|
|
185
|
+
bypass?: ProxyBypass;
|
|
186
|
+
/**
|
|
187
|
+
* Used to proxy multiple specified paths to the same target.
|
|
188
|
+
*/
|
|
189
|
+
context?: ProxyFilter;
|
|
190
|
+
};
|
|
191
|
+
export type ProxyConfig = Record<string, string> | Record<string, ProxyOptions> | ProxyOptions[] | ProxyOptions;
|
|
192
|
+
export type HistoryApiFallbackContext = {
|
|
193
|
+
match: RegExpMatchArray;
|
|
194
|
+
parsedUrl: import('node:url').Url;
|
|
195
|
+
request: Request;
|
|
196
|
+
};
|
|
197
|
+
export type HistoryApiFallbackOptions = {
|
|
198
|
+
index?: string;
|
|
199
|
+
verbose?: boolean;
|
|
200
|
+
logger?: typeof console.log;
|
|
201
|
+
htmlAcceptHeaders?: string[];
|
|
202
|
+
disableDotRule?: true;
|
|
203
|
+
rewrites?: Array<{
|
|
204
|
+
from: RegExp;
|
|
205
|
+
to: string | RegExp | ((context: HistoryApiFallbackContext) => string);
|
|
206
|
+
}>;
|
|
207
|
+
};
|
|
208
|
+
export type PrintUrls = boolean | ((params: {
|
|
209
|
+
urls: string[];
|
|
210
|
+
port: number;
|
|
211
|
+
routes: Routes;
|
|
212
|
+
protocol: string;
|
|
213
|
+
}) => string[] | void);
|
|
214
|
+
export type PublicDirOptions = {
|
|
215
|
+
/**
|
|
216
|
+
* The name of the public directory, can be set as a relative path or an absolute path.
|
|
217
|
+
* @default 'public'
|
|
218
|
+
*/
|
|
219
|
+
name?: string;
|
|
220
|
+
/**
|
|
221
|
+
* Whether to copy files from the publicDir to the distDir on production build
|
|
222
|
+
* @default true
|
|
223
|
+
*/
|
|
224
|
+
copyOnBuild?: boolean;
|
|
225
|
+
/**
|
|
226
|
+
* whether to watch the public directory and reload the page when the files change
|
|
227
|
+
* @default false
|
|
228
|
+
*/
|
|
229
|
+
watch?: boolean;
|
|
230
|
+
};
|
|
231
|
+
export type PublicDir = false | PublicDirOptions | PublicDirOptions[];
|
|
232
|
+
export interface ServerConfig {
|
|
233
|
+
/**
|
|
234
|
+
* Configure the base path of the server.
|
|
235
|
+
*
|
|
236
|
+
* @default '/'
|
|
237
|
+
*/
|
|
238
|
+
base?: string;
|
|
239
|
+
/**
|
|
240
|
+
* Whether to enable gzip compression
|
|
241
|
+
*/
|
|
242
|
+
compress?: boolean;
|
|
243
|
+
/**
|
|
244
|
+
* Serving static files from the directory (by default 'public' directory)
|
|
245
|
+
*/
|
|
246
|
+
publicDir?: PublicDir;
|
|
247
|
+
/**
|
|
248
|
+
* Specify a port number for Rsbuild Server to listen.
|
|
249
|
+
*/
|
|
250
|
+
port?: number;
|
|
251
|
+
/**
|
|
252
|
+
* After configuring this option, you can enable HTTPS Server, and disabling the HTTP Server.
|
|
253
|
+
*/
|
|
254
|
+
https?: HttpsServerOptions | SecureServerSessionOptions;
|
|
255
|
+
/**
|
|
256
|
+
* Used to set the host of Rsbuild Server.
|
|
257
|
+
*/
|
|
258
|
+
host?: string;
|
|
259
|
+
/**
|
|
260
|
+
* Adds headers to all responses.
|
|
261
|
+
*/
|
|
262
|
+
headers?: Record<string, string | string[]>;
|
|
263
|
+
/**
|
|
264
|
+
* Whether to support html fallback.
|
|
265
|
+
*/
|
|
266
|
+
htmlFallback?: HtmlFallback;
|
|
267
|
+
/**
|
|
268
|
+
* Provide alternative pages for some 404 responses or other requests.
|
|
269
|
+
* see https://github.com/bripkens/connect-history-api-fallback
|
|
270
|
+
*/
|
|
271
|
+
historyApiFallback?: boolean | HistoryApiFallbackOptions;
|
|
272
|
+
/**
|
|
273
|
+
* Set the page URL to open when the server starts.
|
|
274
|
+
*/
|
|
275
|
+
open?: boolean | string | string[] | {
|
|
276
|
+
target?: string | string[];
|
|
277
|
+
before?: () => Promise<void> | void;
|
|
278
|
+
};
|
|
279
|
+
/**
|
|
280
|
+
* Configure CORS for the dev server or preview server.
|
|
281
|
+
* - true: enable CORS with default options.
|
|
282
|
+
* - false: disable CORS.
|
|
283
|
+
* - object: enable CORS with the specified options.
|
|
284
|
+
* @default false
|
|
285
|
+
* @link https://github.com/expressjs/cors
|
|
286
|
+
*/
|
|
287
|
+
cors?: boolean | cors.CorsOptions;
|
|
288
|
+
/**
|
|
289
|
+
* Configure proxy rules for the dev server or preview server to proxy requests to the specified service.
|
|
290
|
+
*/
|
|
291
|
+
proxy?: ProxyConfig;
|
|
292
|
+
/**
|
|
293
|
+
* Whether to throw an error when the port is occupied.
|
|
294
|
+
*/
|
|
295
|
+
strictPort?: boolean;
|
|
296
|
+
/**
|
|
297
|
+
* Whether to print the server urls when the server is started.
|
|
298
|
+
*/
|
|
299
|
+
printUrls?: PrintUrls;
|
|
300
|
+
}
|
|
301
|
+
export type NormalizedServerConfig = ServerConfig & Required<Pick<ServerConfig, 'htmlFallback' | 'port' | 'host' | 'compress' | 'strictPort' | 'printUrls' | 'open' | 'base' | 'cors'>>;
|
|
302
|
+
export type SriAlgorithm = 'sha256' | 'sha384' | 'sha512';
|
|
303
|
+
export type SriOptions = {
|
|
304
|
+
algorithm?: SriAlgorithm;
|
|
305
|
+
enable?: boolean | 'auto';
|
|
306
|
+
};
|
|
307
|
+
export interface SecurityConfig {
|
|
308
|
+
/**
|
|
309
|
+
* Adding an nonce attribute to sub-resources introduced by HTML allows the browser to
|
|
310
|
+
* verify the nonce of the introduced resource, thus preventing xss.
|
|
311
|
+
*/
|
|
312
|
+
nonce?: string;
|
|
313
|
+
/**
|
|
314
|
+
* Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to
|
|
315
|
+
* verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource.
|
|
316
|
+
*/
|
|
317
|
+
sri?: SriOptions;
|
|
318
|
+
}
|
|
319
|
+
export type NormalizedSecurityConfig = Required<SecurityConfig>;
|
|
320
|
+
export type ConsoleType = 'log' | 'info' | 'warn' | 'error' | 'table' | 'group';
|
|
321
|
+
export type BuildCacheOptions = {
|
|
322
|
+
/** Base directory for the filesystem cache. */
|
|
323
|
+
cacheDirectory?: string;
|
|
324
|
+
cacheDigest?: Array<string | undefined>;
|
|
325
|
+
};
|
|
326
|
+
export type PrintFileSizeAsset = {
|
|
327
|
+
/**
|
|
328
|
+
* The name of the asset.
|
|
329
|
+
* @example 'index.html', 'static/js/index.[hash].js'
|
|
330
|
+
*/
|
|
331
|
+
name: string;
|
|
332
|
+
/**
|
|
333
|
+
* The size of the asset in bytes.
|
|
334
|
+
*/
|
|
335
|
+
size: number;
|
|
336
|
+
};
|
|
337
|
+
export type PrintFileSizeOptions = {
|
|
338
|
+
/**
|
|
339
|
+
* Whether to print the total size of all static assets.
|
|
340
|
+
* @default true
|
|
341
|
+
*/
|
|
342
|
+
total?: boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Whether to print the size of each static asset.
|
|
345
|
+
* @default true
|
|
346
|
+
*/
|
|
347
|
+
detail?: boolean;
|
|
348
|
+
/**
|
|
349
|
+
* Whether to print the gzip-compressed size of each static asset.
|
|
350
|
+
* Disable this option can save some gzip computation time for large projects.
|
|
351
|
+
* @default true
|
|
352
|
+
*/
|
|
353
|
+
compressed?: boolean;
|
|
354
|
+
/**
|
|
355
|
+
* A filter function to determine which static assets to print.
|
|
356
|
+
* If returned `false`, the static asset will be excluded and not included in the
|
|
357
|
+
* total size or detailed size.
|
|
358
|
+
* @default undefined
|
|
359
|
+
*/
|
|
360
|
+
include?: (asset: PrintFileSizeAsset) => boolean;
|
|
361
|
+
/**
|
|
362
|
+
* A filter function to exclude static assets from the total size or detailed size.
|
|
363
|
+
* If both `include` and `exclude` are set, `exclude` will take precedence.
|
|
364
|
+
* @default (asset) => /\.(?:map|LICENSE\.txt)$/.test(asset.name)
|
|
365
|
+
*/
|
|
366
|
+
exclude?: (asset: PrintFileSizeAsset) => boolean;
|
|
367
|
+
};
|
|
368
|
+
export interface PreconnectOption {
|
|
369
|
+
/**
|
|
370
|
+
* The URL of the resource to preconnect to.
|
|
371
|
+
*/
|
|
372
|
+
href: string;
|
|
373
|
+
/**
|
|
374
|
+
* Whether to add `crossorigin` attribute to the `<link>` element.
|
|
375
|
+
*/
|
|
376
|
+
crossorigin?: boolean;
|
|
377
|
+
}
|
|
378
|
+
export type Preconnect = Array<string | PreconnectOption>;
|
|
379
|
+
export type DnsPrefetch = string[];
|
|
380
|
+
export type PreloadIncludeType = 'async-chunks' | 'initial' | 'all-assets' | 'all-chunks';
|
|
381
|
+
export type Filter = Array<string | RegExp> | ((filename: string) => boolean);
|
|
382
|
+
export interface PreloadOrPreFetchOption {
|
|
383
|
+
type?: PreloadIncludeType;
|
|
384
|
+
include?: Filter;
|
|
385
|
+
exclude?: Filter;
|
|
386
|
+
}
|
|
387
|
+
export interface PerformanceConfig {
|
|
388
|
+
/**
|
|
389
|
+
* Whether to remove `console.[methodName]` in production build.
|
|
390
|
+
*/
|
|
391
|
+
removeConsole?: boolean | ConsoleType[];
|
|
392
|
+
/**
|
|
393
|
+
* Whether to remove the locales of [moment.js](https://momentjs.com/).
|
|
394
|
+
*/
|
|
395
|
+
removeMomentLocale?: boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Controls the Rsbuild's caching behavior during the build process.
|
|
398
|
+
*/
|
|
399
|
+
buildCache?: BuildCacheOptions | boolean;
|
|
400
|
+
/**
|
|
401
|
+
* Whether to print the file sizes after production build.
|
|
402
|
+
*/
|
|
403
|
+
printFileSize?: PrintFileSizeOptions | boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Configure the chunk splitting strategy.
|
|
406
|
+
*/
|
|
407
|
+
chunkSplit?: RsbuildChunkSplit;
|
|
408
|
+
/**
|
|
409
|
+
* Analyze the size of output files.
|
|
410
|
+
*/
|
|
411
|
+
bundleAnalyze?: BundleAnalyzerPlugin.Options;
|
|
412
|
+
/**
|
|
413
|
+
* Used to control resource `Preconnect`.
|
|
414
|
+
*
|
|
415
|
+
* Specifies that the user agent should preemptively connect to the target resource's origin.
|
|
416
|
+
*/
|
|
417
|
+
preconnect?: Preconnect;
|
|
418
|
+
/**
|
|
419
|
+
* Used to control resource `DnsPrefetch`.
|
|
420
|
+
*
|
|
421
|
+
* Specifies that the user agent should preemptively perform DNS resolution for the target resource's origin.
|
|
422
|
+
*/
|
|
423
|
+
dnsPrefetch?: DnsPrefetch;
|
|
424
|
+
/**
|
|
425
|
+
* Used to control resource `Preload`.
|
|
426
|
+
*
|
|
427
|
+
* Specifies that the user agent must preemptively fetch and cache the target resource for current navigation.
|
|
428
|
+
*/
|
|
429
|
+
preload?: true | PreloadOrPreFetchOption;
|
|
430
|
+
/**
|
|
431
|
+
* Used to control resource `Prefetch`.
|
|
432
|
+
*
|
|
433
|
+
* Specifies that the user agent should preemptively fetch and cache the target resource as it
|
|
434
|
+
* is likely to be required for a followup navigation.
|
|
435
|
+
*/
|
|
436
|
+
prefetch?: true | PreloadOrPreFetchOption;
|
|
437
|
+
/**
|
|
438
|
+
* Whether capture timing information for each module,
|
|
439
|
+
* same as the [profile](https://webpack.js.org/configuration/other-options/#profile) config of webpack.
|
|
440
|
+
*/
|
|
441
|
+
profile?: boolean;
|
|
442
|
+
}
|
|
443
|
+
export interface NormalizedPerformanceConfig extends PerformanceConfig {
|
|
444
|
+
printFileSize: PrintFileSizeOptions | boolean;
|
|
445
|
+
buildCache: BuildCacheOptions | boolean;
|
|
446
|
+
chunkSplit: RsbuildChunkSplit;
|
|
447
|
+
}
|
|
448
|
+
export type SplitChunks = Configuration extends {
|
|
449
|
+
optimization?: {
|
|
450
|
+
splitChunks?: infer P;
|
|
451
|
+
};
|
|
452
|
+
} ? P : never;
|
|
453
|
+
export type CacheGroups = Configuration extends {
|
|
454
|
+
optimization?: {
|
|
455
|
+
splitChunks?: {
|
|
456
|
+
cacheGroups?: infer P;
|
|
457
|
+
} | false;
|
|
458
|
+
};
|
|
459
|
+
} ? P : never;
|
|
460
|
+
export type CacheGroup = CacheGroups extends {
|
|
461
|
+
[key: string]: infer P;
|
|
462
|
+
} ? P : null;
|
|
463
|
+
export type ForceSplitting = RegExp[] | Record<string, RegExp>;
|
|
464
|
+
export interface BaseSplitRules {
|
|
465
|
+
strategy?: string;
|
|
466
|
+
forceSplitting?: ForceSplitting;
|
|
467
|
+
override?: SplitChunks;
|
|
468
|
+
}
|
|
469
|
+
export interface BaseChunkSplit extends BaseSplitRules {
|
|
470
|
+
strategy?: 'split-by-module' | 'split-by-experience' | 'all-in-one' | 'single-vendor';
|
|
471
|
+
}
|
|
472
|
+
export interface SplitBySize extends BaseSplitRules {
|
|
473
|
+
strategy: 'split-by-size';
|
|
474
|
+
minSize?: number;
|
|
475
|
+
maxSize?: number;
|
|
476
|
+
}
|
|
477
|
+
export interface SplitCustom extends BaseSplitRules {
|
|
478
|
+
strategy: 'custom';
|
|
479
|
+
splitChunks?: SplitChunks;
|
|
480
|
+
}
|
|
481
|
+
export type RsbuildChunkSplit = BaseChunkSplit | SplitBySize | SplitCustom;
|
|
482
|
+
export type DistPathConfig = {
|
|
483
|
+
/**
|
|
484
|
+
* The root directory of all files.
|
|
485
|
+
* @default 'dist'
|
|
486
|
+
**/
|
|
487
|
+
root?: string;
|
|
488
|
+
/**
|
|
489
|
+
* The output directory of JavaScript files.
|
|
490
|
+
* @default 'static/js'
|
|
491
|
+
*/
|
|
492
|
+
js?: string;
|
|
493
|
+
/**
|
|
494
|
+
* The output directory of async JavaScript files.
|
|
495
|
+
* @default 'static/js/async'
|
|
496
|
+
*/
|
|
497
|
+
jsAsync?: string;
|
|
498
|
+
/**
|
|
499
|
+
* The output directory of CSS files.
|
|
500
|
+
* @default 'static/css'
|
|
501
|
+
*/
|
|
502
|
+
css?: string;
|
|
503
|
+
/**
|
|
504
|
+
* The output directory of async CSS files.
|
|
505
|
+
* @default 'static/css/async'
|
|
506
|
+
*/
|
|
507
|
+
cssAsync?: string;
|
|
508
|
+
/**
|
|
509
|
+
* The output directory of SVG images.
|
|
510
|
+
* @default 'static/svg'
|
|
511
|
+
*/
|
|
512
|
+
svg?: string;
|
|
513
|
+
/**
|
|
514
|
+
* The output directory of font files.
|
|
515
|
+
* @default 'static/font'
|
|
516
|
+
*/
|
|
517
|
+
font?: string;
|
|
518
|
+
/**
|
|
519
|
+
* The output directory of HTML files.
|
|
520
|
+
* @default '/'
|
|
521
|
+
*/
|
|
522
|
+
html?: string;
|
|
523
|
+
/**
|
|
524
|
+
* The output directory of Wasm files.
|
|
525
|
+
* @default 'static/wasm'
|
|
526
|
+
*/
|
|
527
|
+
wasm?: string;
|
|
528
|
+
/**
|
|
529
|
+
* The output directory of non-SVG images.
|
|
530
|
+
* @default 'static/image'
|
|
531
|
+
*/
|
|
532
|
+
image?: string;
|
|
533
|
+
/**
|
|
534
|
+
* The output directory of media resources, such as videos.
|
|
535
|
+
* @default 'static/media'
|
|
536
|
+
*/
|
|
537
|
+
media?: string;
|
|
538
|
+
/**
|
|
539
|
+
* The output directory of assets, except for above (image, svg, font, html, wasm...)
|
|
540
|
+
* @default 'static/assets'
|
|
541
|
+
*/
|
|
542
|
+
assets?: string;
|
|
543
|
+
};
|
|
544
|
+
export type FilenameConfig = {
|
|
545
|
+
/**
|
|
546
|
+
* The name of the JavaScript files.
|
|
547
|
+
* @default
|
|
548
|
+
* - dev: '[name].js'
|
|
549
|
+
* - prod: '[name].[contenthash:8].js'
|
|
550
|
+
*/
|
|
551
|
+
js?: NonNullable<Rspack.Configuration['output']>['filename'];
|
|
552
|
+
/**
|
|
553
|
+
* The name of the CSS files.
|
|
554
|
+
* @default
|
|
555
|
+
* - dev: '[name].css'
|
|
556
|
+
* - prod: '[name].[contenthash:8].css'
|
|
557
|
+
*/
|
|
558
|
+
css?: NonNullable<Rspack.Configuration['output']>['cssFilename'];
|
|
559
|
+
/**
|
|
560
|
+
* The name of the SVG images.
|
|
561
|
+
* @default '[name].[contenthash:8].svg'
|
|
562
|
+
*/
|
|
563
|
+
svg?: string;
|
|
564
|
+
/**
|
|
565
|
+
* The name of HTML files.
|
|
566
|
+
* @default `[name].html`
|
|
567
|
+
*/
|
|
568
|
+
html?: string;
|
|
569
|
+
/**
|
|
570
|
+
* The name of the font files.
|
|
571
|
+
* @default '[name].[contenthash:8][ext]'
|
|
572
|
+
*/
|
|
573
|
+
font?: string;
|
|
574
|
+
/**
|
|
575
|
+
* The name of non-SVG images.
|
|
576
|
+
* @default '[name].[contenthash:8][ext]'
|
|
577
|
+
*/
|
|
578
|
+
image?: string;
|
|
579
|
+
/**
|
|
580
|
+
* The name of media assets, such as video.
|
|
581
|
+
* @default '[name].[contenthash:8][ext]'
|
|
582
|
+
*/
|
|
583
|
+
media?: string;
|
|
584
|
+
/**
|
|
585
|
+
* the name of other assets, except for above (image, svg, font, html, wasm...)
|
|
586
|
+
* @default '[name].[contenthash:8][ext]'
|
|
587
|
+
*/
|
|
588
|
+
assets?: string;
|
|
589
|
+
};
|
|
590
|
+
export type DataUriLimit = {
|
|
591
|
+
/**
|
|
592
|
+
* The data URI limit of the SVG image.
|
|
593
|
+
* @default 4096
|
|
594
|
+
*/
|
|
595
|
+
svg?: number;
|
|
596
|
+
/**
|
|
597
|
+
* The data URI limit of the font file.
|
|
598
|
+
* @default 4096
|
|
599
|
+
*/
|
|
600
|
+
font?: number;
|
|
601
|
+
/**
|
|
602
|
+
* The data URI limit of non-SVG images.
|
|
603
|
+
* @default 4096
|
|
604
|
+
*/
|
|
605
|
+
image?: number;
|
|
606
|
+
/**
|
|
607
|
+
* The data URI limit of media resources such as videos.
|
|
608
|
+
* @default 4096
|
|
609
|
+
*/
|
|
610
|
+
media?: number;
|
|
611
|
+
/**
|
|
612
|
+
* The data URI limit of other static assets.
|
|
613
|
+
* @default 4096
|
|
614
|
+
*/
|
|
615
|
+
assets?: number;
|
|
616
|
+
};
|
|
617
|
+
export type Charset = 'ascii' | 'utf8';
|
|
618
|
+
export type LegalComments = 'none' | 'inline' | 'linked';
|
|
619
|
+
export type NormalizedDataUriLimit = Required<DataUriLimit>;
|
|
620
|
+
export type Polyfill = 'usage' | 'entry' | 'off';
|
|
621
|
+
export type SourceMap = {
|
|
622
|
+
/**
|
|
623
|
+
* The source map type for JavaScript files.
|
|
624
|
+
* @default isDev ? 'cheap-module-source-map' : false
|
|
625
|
+
*/
|
|
626
|
+
js?: Rspack.Configuration['devtool'];
|
|
627
|
+
/**
|
|
628
|
+
* Whether to generate source map for CSS files.
|
|
629
|
+
* @default false
|
|
630
|
+
*/
|
|
631
|
+
css?: boolean;
|
|
632
|
+
};
|
|
633
|
+
export type CSSModulesLocalsConvention = 'asIs' | 'camelCase' | 'camelCaseOnly' | 'dashes' | 'dashesOnly';
|
|
634
|
+
export type CSSModules = {
|
|
635
|
+
/**
|
|
636
|
+
* Allows CSS Modules to be automatically enabled based on their filenames.
|
|
637
|
+
* @default true
|
|
638
|
+
*/
|
|
639
|
+
auto?: CSSLoaderModulesOptions['auto'];
|
|
640
|
+
/**
|
|
641
|
+
* Allows exporting names from global class names, so you can use them via import.
|
|
642
|
+
* @default false
|
|
643
|
+
*/
|
|
644
|
+
exportGlobals?: boolean;
|
|
645
|
+
/**
|
|
646
|
+
* Style of exported class names.
|
|
647
|
+
* @default 'camelCase'
|
|
648
|
+
*/
|
|
649
|
+
exportLocalsConvention?: CSSModulesLocalsConvention;
|
|
650
|
+
/**
|
|
651
|
+
* Set the local ident name of CSS Modules.
|
|
652
|
+
* @default isProd ? '[local]-[hash:base64:6]' : '[path][name]__[local]-[hash:base64:6]'
|
|
653
|
+
*/
|
|
654
|
+
localIdentName?: string;
|
|
655
|
+
/**
|
|
656
|
+
* Controls the level of compilation applied to the input styles.
|
|
657
|
+
* @default 'local'
|
|
658
|
+
*/
|
|
659
|
+
mode?: CSSLoaderModulesOptions['mode'];
|
|
660
|
+
/**
|
|
661
|
+
* Whether to enable ES modules named export for locals.
|
|
662
|
+
* @default false
|
|
663
|
+
*/
|
|
664
|
+
namedExport?: boolean;
|
|
665
|
+
};
|
|
666
|
+
export type Minify = boolean | {
|
|
667
|
+
/**
|
|
668
|
+
* Whether to enable JavaScript minification.
|
|
669
|
+
*/
|
|
670
|
+
js?: boolean;
|
|
671
|
+
/**
|
|
672
|
+
* Minimizer options of JavaScript, which will be passed to SWC.
|
|
673
|
+
*/
|
|
674
|
+
jsOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
675
|
+
/**
|
|
676
|
+
* Whether to enable CSS minimization.
|
|
677
|
+
*/
|
|
678
|
+
css?: boolean;
|
|
679
|
+
/**
|
|
680
|
+
* Minimizer options of CSS, which will be passed to LightningCSS.
|
|
681
|
+
*/
|
|
682
|
+
cssOptions?: LightningCssMinimizerRspackPluginOptions;
|
|
683
|
+
};
|
|
684
|
+
export type InlineChunkTestFunction = (params: {
|
|
685
|
+
size: number;
|
|
686
|
+
name: string;
|
|
687
|
+
}) => boolean;
|
|
688
|
+
export type InlineChunkTest = RegExp | InlineChunkTestFunction;
|
|
689
|
+
export type InlineChunkConfig = boolean | InlineChunkTest | {
|
|
690
|
+
enable?: boolean | 'auto';
|
|
691
|
+
test: InlineChunkTest;
|
|
692
|
+
};
|
|
693
|
+
export interface OutputConfig {
|
|
694
|
+
/**
|
|
695
|
+
* Specify build target to run in specified environment.
|
|
696
|
+
* @default 'web'
|
|
697
|
+
*/
|
|
698
|
+
target?: RsbuildTarget;
|
|
699
|
+
/**
|
|
700
|
+
* At build time, prevent some `import` dependencies from being packed into bundles in your code,
|
|
701
|
+
* and instead fetch them externally at runtime.
|
|
702
|
+
* For more information, please see: [Rspack Externals](https://rspack.dev/config/externals)
|
|
703
|
+
* @default undefined
|
|
704
|
+
*/
|
|
705
|
+
externals?: Externals;
|
|
706
|
+
/**
|
|
707
|
+
* Set the directory of the dist files.
|
|
708
|
+
* Rsbuild will output files to the corresponding subdirectory according to the file type.
|
|
709
|
+
*/
|
|
710
|
+
distPath?: DistPathConfig;
|
|
711
|
+
/**
|
|
712
|
+
* Sets the filename of dist files.
|
|
713
|
+
*/
|
|
714
|
+
filename?: FilenameConfig;
|
|
715
|
+
/**
|
|
716
|
+
* Specify the character encoding format for output files.
|
|
717
|
+
* Can be `ascii` or `utf8`.
|
|
718
|
+
* @default 'utf8'
|
|
719
|
+
*/
|
|
720
|
+
charset?: Charset;
|
|
721
|
+
/**
|
|
722
|
+
* Configure how the polyfill is injected.
|
|
723
|
+
* @default 'off'
|
|
724
|
+
*/
|
|
725
|
+
polyfill?: Polyfill;
|
|
726
|
+
/**
|
|
727
|
+
* When using CDN in the production,
|
|
728
|
+
* you can use this option to set the URL prefix of static assets,
|
|
729
|
+
* similar to the output.publicPath config of webpack.
|
|
730
|
+
* @default `server.base`
|
|
731
|
+
*/
|
|
732
|
+
assetPrefix?: string;
|
|
733
|
+
/**
|
|
734
|
+
* Set the size threshold to inline static assets such as images and fonts.
|
|
735
|
+
* By default, static assets will be Base64 encoded and inline into the page if the size is less than 4KiB.
|
|
736
|
+
*/
|
|
737
|
+
dataUriLimit?: number | DataUriLimit;
|
|
738
|
+
/**
|
|
739
|
+
* Configure how to handle the legal comment.
|
|
740
|
+
* A "legal comment" is considered to be any statement-level comment in JS or rule-level
|
|
741
|
+
* comment in CSS that contains @license or @preserve or that starts with //! or /\*!.
|
|
742
|
+
* These comments are preserved in output files by default since that follows the intent
|
|
743
|
+
* of the original authors of the code.
|
|
744
|
+
* @default 'linked'
|
|
745
|
+
*/
|
|
746
|
+
legalComments?: LegalComments;
|
|
747
|
+
/**
|
|
748
|
+
* Whether to clean all files in the dist path before starting compilation.
|
|
749
|
+
* @default 'auto'
|
|
750
|
+
*/
|
|
751
|
+
cleanDistPath?: boolean | 'auto';
|
|
752
|
+
/**
|
|
753
|
+
* Allow to custom CSS Modules options.
|
|
754
|
+
*/
|
|
755
|
+
cssModules?: CSSModules;
|
|
756
|
+
/**
|
|
757
|
+
* Whether to disable code minification in production build.
|
|
758
|
+
* @default true
|
|
759
|
+
*/
|
|
760
|
+
minify?: Minify;
|
|
761
|
+
/**
|
|
762
|
+
* Whether to generate manifest file.
|
|
763
|
+
* @default false
|
|
764
|
+
*/
|
|
765
|
+
manifest?: string | boolean;
|
|
766
|
+
/**
|
|
767
|
+
* Whether to generate source map files, and which format of source map to generate.
|
|
768
|
+
*
|
|
769
|
+
* @default
|
|
770
|
+
* ```js
|
|
771
|
+
* const defaultSourceMap = {
|
|
772
|
+
* js: isDev ? 'cheap-module-source-map' : false,
|
|
773
|
+
* css: false,
|
|
774
|
+
* };
|
|
775
|
+
* ```
|
|
776
|
+
*/
|
|
777
|
+
sourceMap?: boolean | SourceMap;
|
|
778
|
+
/**
|
|
779
|
+
* Whether to add filename hash after production build.
|
|
780
|
+
* @default true
|
|
781
|
+
*/
|
|
782
|
+
filenameHash?: boolean | string;
|
|
783
|
+
/**
|
|
784
|
+
* Whether to inline output scripts files (.js files) into HTML with `<script>` tags.
|
|
785
|
+
* @default false
|
|
786
|
+
*/
|
|
787
|
+
inlineScripts?: InlineChunkConfig;
|
|
788
|
+
/**
|
|
789
|
+
* Whether to inline output style files (.css files) into html with `<style>` tags.
|
|
790
|
+
* @default false
|
|
791
|
+
*/
|
|
792
|
+
inlineStyles?: InlineChunkConfig;
|
|
793
|
+
/**
|
|
794
|
+
* Whether to inject styles into the DOM via `style-loader`.
|
|
795
|
+
* @default false
|
|
796
|
+
*/
|
|
797
|
+
injectStyles?: boolean;
|
|
798
|
+
/**
|
|
799
|
+
* Specifies the range of target browsers that the project is compatible with.
|
|
800
|
+
* This value will be used by [SWC](https://github.com/swc-project/swc) and
|
|
801
|
+
* [Lightning CSS](https://github.com/parcel-bundler/lightningcss) to identify the JavaScript syntax that
|
|
802
|
+
* need to be transformed and the CSS browser prefixes that need to be added.
|
|
803
|
+
* @default undefined
|
|
804
|
+
*/
|
|
805
|
+
overrideBrowserslist?: string[];
|
|
806
|
+
/**
|
|
807
|
+
* Copies the specified file or directory to the dist directory.
|
|
808
|
+
* @default undefined
|
|
809
|
+
*/
|
|
810
|
+
copy?: CopyRspackPluginOptions | CopyRspackPluginOptions['patterns'];
|
|
811
|
+
/**
|
|
812
|
+
* Whether to emit static assets such as image, font, etc.
|
|
813
|
+
* Return `false` to avoid outputting unnecessary assets for some scenarios such as SSR.
|
|
814
|
+
* @default true
|
|
815
|
+
*/
|
|
816
|
+
emitAssets?: boolean;
|
|
817
|
+
/**
|
|
818
|
+
* Whether to emit CSS to the output bundles.
|
|
819
|
+
* If `false`, the CSS will not be extracted to separate files or injected into the JavaScript
|
|
820
|
+
* bundles via `output.injectStyles`.
|
|
821
|
+
* @default `true` when `output.target` is `web`, otherwise `false`
|
|
822
|
+
*/
|
|
823
|
+
emitCss?: boolean;
|
|
824
|
+
}
|
|
825
|
+
export interface NormalizedOutputConfig extends OutputConfig {
|
|
826
|
+
target: RsbuildTarget;
|
|
827
|
+
filename: FilenameConfig;
|
|
828
|
+
distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync' | 'js'> & Pick<DistPathConfig, 'jsAsync' | 'cssAsync' | 'js'>;
|
|
829
|
+
polyfill: Polyfill;
|
|
830
|
+
sourceMap: boolean | {
|
|
831
|
+
js?: Rspack.Configuration['devtool'];
|
|
832
|
+
css: boolean;
|
|
833
|
+
};
|
|
834
|
+
filenameHash: boolean | string;
|
|
835
|
+
assetPrefix: string;
|
|
836
|
+
dataUriLimit: number | NormalizedDataUriLimit;
|
|
837
|
+
minify: Minify;
|
|
838
|
+
inlineScripts: InlineChunkConfig;
|
|
839
|
+
inlineStyles: InlineChunkConfig;
|
|
840
|
+
injectStyles: boolean;
|
|
841
|
+
cssModules: {
|
|
842
|
+
auto: CSSModules['auto'];
|
|
843
|
+
namedExport: boolean;
|
|
844
|
+
exportGlobals: boolean;
|
|
845
|
+
exportLocalsConvention: CSSModulesLocalsConvention;
|
|
846
|
+
localIdentName?: string;
|
|
847
|
+
mode?: CSSModules['mode'];
|
|
848
|
+
};
|
|
849
|
+
emitAssets: boolean;
|
|
850
|
+
}
|
|
851
|
+
export type CrossOrigin = 'anonymous' | 'use-credentials';
|
|
852
|
+
export type ScriptInject = boolean | 'body' | 'head';
|
|
853
|
+
export type ScriptLoading = 'defer' | 'module' | 'blocking';
|
|
854
|
+
export type OutputStructure = 'flat' | 'nested';
|
|
855
|
+
/**
|
|
856
|
+
* custom properties
|
|
857
|
+
* e.g. { name: 'viewport' content: 'width=500, initial-scale=1' }
|
|
858
|
+
* */
|
|
859
|
+
export type MetaAttrs = {
|
|
860
|
+
[attrName: string]: string | boolean;
|
|
861
|
+
};
|
|
862
|
+
export type MetaOptions = {
|
|
863
|
+
/**
|
|
864
|
+
* name content pair
|
|
865
|
+
* e.g. { viewport: 'width=device-width, initial-scale=1, shrink-to-fit=no' }`
|
|
866
|
+
* */
|
|
867
|
+
[name: string]: string | false | MetaAttrs;
|
|
868
|
+
};
|
|
869
|
+
export type HtmlBasicTag = {
|
|
870
|
+
tag: string;
|
|
871
|
+
attrs?: Record<string, string | boolean | null | undefined>;
|
|
872
|
+
children?: string;
|
|
873
|
+
};
|
|
874
|
+
export type HtmlTag = HtmlBasicTag & {
|
|
875
|
+
hash?: boolean | string | ((url: string, hash: string) => string);
|
|
876
|
+
publicPath?: boolean | string | ((url: string, publicPath: string) => string);
|
|
877
|
+
append?: boolean;
|
|
878
|
+
head?: boolean;
|
|
879
|
+
};
|
|
880
|
+
export type HtmlTagContext = {
|
|
881
|
+
hash: string;
|
|
882
|
+
entryName: string;
|
|
883
|
+
outputName: string;
|
|
884
|
+
publicPath: string;
|
|
885
|
+
};
|
|
886
|
+
export type HtmlTagHandler = (tags: HtmlTag[], context: HtmlTagContext) => HtmlTag[] | void;
|
|
887
|
+
export type HtmlTagDescriptor = HtmlTag | HtmlTagHandler;
|
|
888
|
+
type ChainedHtmlOption<O> = ConfigChainMergeContext<O, {
|
|
889
|
+
entryName: string;
|
|
890
|
+
}>;
|
|
891
|
+
export type AppIconItem = {
|
|
892
|
+
/**
|
|
893
|
+
* The path to the icon, can be a URL, an absolute file path,
|
|
894
|
+
* or a relative path to the project root.
|
|
895
|
+
*/
|
|
896
|
+
src: string;
|
|
897
|
+
/**
|
|
898
|
+
* The size of the icon.
|
|
899
|
+
*/
|
|
900
|
+
size: number;
|
|
901
|
+
/**
|
|
902
|
+
* Specifies the intended target for which the icon should be generated.
|
|
903
|
+
* - `apple-touch-icon` for iOS system.
|
|
904
|
+
* - `web-app-manifest` for web application manifest.
|
|
905
|
+
*/
|
|
906
|
+
target?: 'apple-touch-icon' | 'web-app-manifest';
|
|
907
|
+
};
|
|
908
|
+
export type AppIcon = {
|
|
909
|
+
/**
|
|
910
|
+
* The name of the application.
|
|
911
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/Manifest/name
|
|
912
|
+
*/
|
|
913
|
+
name?: string;
|
|
914
|
+
/**
|
|
915
|
+
* The list of icons.
|
|
916
|
+
*/
|
|
917
|
+
icons: AppIconItem[];
|
|
918
|
+
/**
|
|
919
|
+
* The filename of the manifest file.
|
|
920
|
+
* @default 'manifest.webmanifest'
|
|
921
|
+
*/
|
|
922
|
+
filename?: string;
|
|
923
|
+
};
|
|
924
|
+
export interface HtmlConfig {
|
|
925
|
+
/**
|
|
926
|
+
* Configure the `<meta>` tag of the HTML.
|
|
927
|
+
*
|
|
928
|
+
* @default
|
|
929
|
+
* ```js
|
|
930
|
+
* const defaultMeta = {
|
|
931
|
+
* charset: { charset: 'UTF-8' },
|
|
932
|
+
* viewport: 'width=device-width, initial-scale=1.0',
|
|
933
|
+
* };
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
meta?: ChainedHtmlOption<MetaOptions>;
|
|
937
|
+
/**
|
|
938
|
+
* Set the title tag of the HTML page.
|
|
939
|
+
* @default 'Rsbuild App'
|
|
940
|
+
*/
|
|
941
|
+
title?: ChainedHtmlOption<string>;
|
|
942
|
+
/**
|
|
943
|
+
* Set the inject position of the `<script>` tag.
|
|
944
|
+
* @default 'head'
|
|
945
|
+
*/
|
|
946
|
+
inject?: ChainedHtmlOption<ScriptInject>;
|
|
947
|
+
/**
|
|
948
|
+
* Inject custom html tags into the output html files.
|
|
949
|
+
* @default undefined
|
|
950
|
+
*/
|
|
951
|
+
tags?: OneOrMany<HtmlTagDescriptor>;
|
|
952
|
+
/**
|
|
953
|
+
* Set the favicon icon for all pages.
|
|
954
|
+
* @default undefined
|
|
955
|
+
*/
|
|
956
|
+
favicon?: ChainedHtmlOption<string>;
|
|
957
|
+
/**
|
|
958
|
+
* Set the web application icons to display when added to the home screen of a mobile device.
|
|
959
|
+
*
|
|
960
|
+
* @default undefined
|
|
961
|
+
* @example
|
|
962
|
+
* appIcon: {
|
|
963
|
+
* name: 'My Website',
|
|
964
|
+
* icons: [
|
|
965
|
+
* { src: './icon-192.png', size: 192 },
|
|
966
|
+
* { src: './icon-512.png', size: 512 },
|
|
967
|
+
* ]
|
|
968
|
+
* }
|
|
969
|
+
*/
|
|
970
|
+
appIcon?: AppIcon;
|
|
971
|
+
/**
|
|
972
|
+
* Set the id of root element.
|
|
973
|
+
* @default 'root'
|
|
974
|
+
*/
|
|
975
|
+
mountId?: string;
|
|
976
|
+
/**
|
|
977
|
+
* Set the [crossorigin](https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/crossorigin) attribute
|
|
978
|
+
* of the `<script>` tag.
|
|
979
|
+
* @default false
|
|
980
|
+
*/
|
|
981
|
+
crossorigin?: boolean | CrossOrigin;
|
|
982
|
+
/**
|
|
983
|
+
* Define the directory structure of the HTML output files.
|
|
984
|
+
* @default 'flat'
|
|
985
|
+
*/
|
|
986
|
+
outputStructure?: OutputStructure;
|
|
987
|
+
/**
|
|
988
|
+
* Define the path to the HTML template,
|
|
989
|
+
* corresponding to the `template` config of [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin).
|
|
990
|
+
* @default A built-in HTML template
|
|
991
|
+
*/
|
|
992
|
+
template?: ChainedHtmlOption<string>;
|
|
993
|
+
/**
|
|
994
|
+
* Define the parameters in the HTML template,
|
|
995
|
+
* corresponding to the `templateParameters` config of [html-rspack-plugin](https://github.com/rspack-contrib/html-rspack-plugin).
|
|
996
|
+
*/
|
|
997
|
+
templateParameters?: ConfigChainWithContext<Record<string, unknown>, {
|
|
998
|
+
entryName: string;
|
|
999
|
+
}>;
|
|
1000
|
+
/**
|
|
1001
|
+
* Set the loading mode of the `<script>` tag.
|
|
1002
|
+
* @default 'defer'
|
|
1003
|
+
*/
|
|
1004
|
+
scriptLoading?: ScriptLoading;
|
|
1005
|
+
}
|
|
1006
|
+
export type NormalizedHtmlConfig = HtmlConfig & {
|
|
1007
|
+
meta: ChainedHtmlOption<MetaOptions>;
|
|
1008
|
+
title: ChainedHtmlOption<string>;
|
|
1009
|
+
mountId: string;
|
|
1010
|
+
inject: ChainedHtmlOption<ScriptInject>;
|
|
1011
|
+
crossorigin: boolean | CrossOrigin;
|
|
1012
|
+
outputStructure: OutputStructure;
|
|
1013
|
+
scriptLoading: ScriptLoading;
|
|
1014
|
+
};
|
|
1015
|
+
export type ProgressBarConfig = {
|
|
1016
|
+
id?: string;
|
|
1017
|
+
};
|
|
1018
|
+
export type NextFunction = () => void;
|
|
1019
|
+
export type RequestHandler = (req: IncomingMessage, res: ServerResponse, next: NextFunction) => void;
|
|
1020
|
+
export type EnvironmentAPI = {
|
|
1021
|
+
[name: string]: {
|
|
1022
|
+
/**
|
|
1023
|
+
* Get stats info about current environment.
|
|
1024
|
+
*/
|
|
1025
|
+
getStats: () => Promise<Rspack.Stats>;
|
|
1026
|
+
/**
|
|
1027
|
+
* Load and execute stats bundle in Server.
|
|
1028
|
+
*
|
|
1029
|
+
* @param entryName - relate to rsbuild source.entry
|
|
1030
|
+
* @returns the return of entry module.
|
|
1031
|
+
*/
|
|
1032
|
+
loadBundle: <T = unknown>(entryName: string) => Promise<T>;
|
|
1033
|
+
/**
|
|
1034
|
+
* Get the compiled HTML template.
|
|
1035
|
+
*/
|
|
1036
|
+
getTransformedHtml: (entryName: string) => Promise<string>;
|
|
1037
|
+
};
|
|
1038
|
+
};
|
|
1039
|
+
export type SetupMiddlewaresServer = {
|
|
1040
|
+
sockWrite: (type: string, data?: string | boolean | Record<string, any>) => void;
|
|
1041
|
+
environments: EnvironmentAPI;
|
|
1042
|
+
};
|
|
1043
|
+
export type SetupMiddlewaresFn = (middlewares: {
|
|
1044
|
+
unshift: (...handlers: RequestHandler[]) => void;
|
|
1045
|
+
push: (...handlers: RequestHandler[]) => void;
|
|
1046
|
+
}, server: SetupMiddlewaresServer) => void;
|
|
1047
|
+
export type ClientConfig = {
|
|
1048
|
+
/**
|
|
1049
|
+
* The path for the WebSocket request.
|
|
1050
|
+
* @default '/rsbuild-hmr'
|
|
1051
|
+
*/
|
|
1052
|
+
path?: string;
|
|
1053
|
+
/**
|
|
1054
|
+
* The port number for the WebSocket request.
|
|
1055
|
+
* @default location.port
|
|
1056
|
+
*/
|
|
1057
|
+
port?: string | number;
|
|
1058
|
+
/**
|
|
1059
|
+
* The host for the WebSocket request.
|
|
1060
|
+
* @default location.hostname
|
|
1061
|
+
*/
|
|
1062
|
+
host?: string;
|
|
1063
|
+
/**
|
|
1064
|
+
* The protocol name for the WebSocket request.
|
|
1065
|
+
* @default location.protocol === 'https:' ? 'wss' : 'ws'
|
|
1066
|
+
*/
|
|
1067
|
+
protocol?: 'ws' | 'wss';
|
|
1068
|
+
/**
|
|
1069
|
+
* The maximum number of reconnection attempts after a WebSocket request is disconnected.
|
|
1070
|
+
* @default 100
|
|
1071
|
+
*/
|
|
1072
|
+
reconnect?: number;
|
|
1073
|
+
/**
|
|
1074
|
+
* Whether to display an error overlay in the browser when a compilation error occurs.
|
|
1075
|
+
* @default true
|
|
1076
|
+
*/
|
|
1077
|
+
overlay?: boolean;
|
|
1078
|
+
};
|
|
1079
|
+
export type NormalizedClientConfig = Pick<ClientConfig, 'protocol'> & Omit<Required<ClientConfig>, 'protocol'>;
|
|
1080
|
+
export type { ChokidarOptions };
|
|
1081
|
+
export type WatchFiles = {
|
|
1082
|
+
paths: string | string[];
|
|
1083
|
+
options?: ChokidarOptions;
|
|
1084
|
+
type?: 'reload-page' | 'reload-server';
|
|
1085
|
+
};
|
|
1086
|
+
export type CliShortcut = {
|
|
1087
|
+
/**
|
|
1088
|
+
* The key to trigger the shortcut.
|
|
1089
|
+
*/
|
|
1090
|
+
key: string;
|
|
1091
|
+
/**
|
|
1092
|
+
* The description of the shortcut.
|
|
1093
|
+
*/
|
|
1094
|
+
description: string;
|
|
1095
|
+
/**
|
|
1096
|
+
* The action to execute when the shortcut is triggered.
|
|
1097
|
+
*/
|
|
1098
|
+
action: () => void | Promise<void>;
|
|
1099
|
+
};
|
|
1100
|
+
export interface DevConfig {
|
|
1101
|
+
/**
|
|
1102
|
+
* Whether to enable Hot Module Replacement.
|
|
1103
|
+
*/
|
|
1104
|
+
hmr?: boolean;
|
|
1105
|
+
/**
|
|
1106
|
+
* Whether to reload the page when file changes are detected.
|
|
1107
|
+
*/
|
|
1108
|
+
liveReload?: boolean;
|
|
1109
|
+
/**
|
|
1110
|
+
* Set the URL prefix of static assets in development mode,
|
|
1111
|
+
* similar to the [output.publicPath](https://rspack.dev/config/output#outputpublicpath) config of webpack.
|
|
1112
|
+
*/
|
|
1113
|
+
assetPrefix?: string | boolean;
|
|
1114
|
+
/**
|
|
1115
|
+
* Whether to display progress bar during compilation.
|
|
1116
|
+
*/
|
|
1117
|
+
progressBar?: boolean | ProgressBarConfig;
|
|
1118
|
+
/**
|
|
1119
|
+
* Config for Rsbuild client code.
|
|
1120
|
+
*/
|
|
1121
|
+
client?: ClientConfig;
|
|
1122
|
+
/**
|
|
1123
|
+
* Whether to enable CLI shortcuts.
|
|
1124
|
+
*/
|
|
1125
|
+
cliShortcuts?: boolean | {
|
|
1126
|
+
/**
|
|
1127
|
+
* Customize the CLI shortcuts.
|
|
1128
|
+
* @param shortcuts - The default CLI shortcuts.
|
|
1129
|
+
* @returns - The customized CLI shortcuts.
|
|
1130
|
+
*/
|
|
1131
|
+
custom?: (shortcuts: CliShortcut[]) => CliShortcut[];
|
|
1132
|
+
/**
|
|
1133
|
+
* Whether to print the help hint when the server is started.
|
|
1134
|
+
* @default true
|
|
1135
|
+
*/
|
|
1136
|
+
help?: boolean;
|
|
1137
|
+
};
|
|
1138
|
+
/**
|
|
1139
|
+
* Provides the ability to execute a custom function and apply custom middlewares.
|
|
1140
|
+
*/
|
|
1141
|
+
setupMiddlewares?: SetupMiddlewaresFn[];
|
|
1142
|
+
/**
|
|
1143
|
+
* Controls whether the build output from development mode is written to disk.
|
|
1144
|
+
* @default false
|
|
1145
|
+
*/
|
|
1146
|
+
writeToDisk?: boolean | ((filename: string) => boolean);
|
|
1147
|
+
/**
|
|
1148
|
+
* This option allows you to configure a list of globs/directories/files to watch for file changes.
|
|
1149
|
+
*/
|
|
1150
|
+
watchFiles?: WatchFiles | WatchFiles[];
|
|
1151
|
+
/**
|
|
1152
|
+
* Enable lazy compilation.
|
|
1153
|
+
* @default false
|
|
1154
|
+
*/
|
|
1155
|
+
lazyCompilation?: boolean | Rspack.LazyCompilationOptions;
|
|
1156
|
+
}
|
|
1157
|
+
export type NormalizedDevConfig = DevConfig & Required<Pick<DevConfig, 'hmr' | 'liveReload' | 'assetPrefix' | 'writeToDisk' | 'cliShortcuts'>> & {
|
|
1158
|
+
client: NormalizedClientConfig;
|
|
1159
|
+
};
|
|
1160
|
+
export interface ResolveConfig {
|
|
1161
|
+
/**
|
|
1162
|
+
* Force Rsbuild to resolve the specified packages from project root,
|
|
1163
|
+
* which is useful for deduplicating packages and reducing the bundle size.
|
|
1164
|
+
*/
|
|
1165
|
+
dedupe?: string[];
|
|
1166
|
+
/**
|
|
1167
|
+
* Create aliases to import or require certain modules,
|
|
1168
|
+
* same as the [resolve.alias](https://rspack.dev/config/resolve) config of Rspack.
|
|
1169
|
+
*/
|
|
1170
|
+
alias?: ConfigChain<Alias>;
|
|
1171
|
+
/**
|
|
1172
|
+
* Control the priority between the `paths` option in `tsconfig.json`
|
|
1173
|
+
* and the `resolve.alias` option of Rsbuild.
|
|
1174
|
+
* @default 'prefer-tsconfig'
|
|
1175
|
+
*/
|
|
1176
|
+
aliasStrategy?: AliasStrategy;
|
|
1177
|
+
/**
|
|
1178
|
+
* Automatically resolve file extensions when importing modules.
|
|
1179
|
+
* This means you can import files without explicitly writing their extensions.
|
|
1180
|
+
* @default ['.ts', '.tsx', '.mjs', '.js', '.jsx', '.json']
|
|
1181
|
+
*/
|
|
1182
|
+
extensions?: string[];
|
|
1183
|
+
}
|
|
1184
|
+
export type NormalizedResolveConfig = ResolveConfig & Pick<Required<ResolveConfig>, 'alias' | 'aliasStrategy' | 'extensions'>;
|
|
1185
|
+
export type ModuleFederationConfig = {
|
|
1186
|
+
options: ModuleFederationPluginOptions;
|
|
1187
|
+
};
|
|
1188
|
+
export type NormalizedModuleFederationConfig = ModuleFederationConfig;
|
|
1189
|
+
export type RsbuildConfigMeta = {
|
|
1190
|
+
/**
|
|
1191
|
+
* Path to the rsbuild config file.
|
|
1192
|
+
*/
|
|
1193
|
+
configFilePath: string;
|
|
1194
|
+
};
|
|
1195
|
+
/**
|
|
1196
|
+
* The Rsbuild config to run in the specified environment.
|
|
1197
|
+
* */
|
|
1198
|
+
export interface EnvironmentConfig {
|
|
1199
|
+
/**
|
|
1200
|
+
* Options for local development.
|
|
1201
|
+
*/
|
|
1202
|
+
dev?: Pick<DevConfig, 'hmr' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk'>;
|
|
1203
|
+
/**
|
|
1204
|
+
* Options for HTML generation.
|
|
1205
|
+
*/
|
|
1206
|
+
html?: HtmlConfig;
|
|
1207
|
+
/**
|
|
1208
|
+
* Options for the low-level tools.
|
|
1209
|
+
*/
|
|
1210
|
+
tools?: ToolsConfig;
|
|
1211
|
+
/**
|
|
1212
|
+
* Options for module resolution.
|
|
1213
|
+
*/
|
|
1214
|
+
resolve?: ResolveConfig;
|
|
1215
|
+
/**
|
|
1216
|
+
* Options for input source code.
|
|
1217
|
+
*/
|
|
1218
|
+
source?: SourceConfig;
|
|
1219
|
+
/**
|
|
1220
|
+
* Options for build outputs.
|
|
1221
|
+
*/
|
|
1222
|
+
output?: OutputConfig;
|
|
1223
|
+
/**
|
|
1224
|
+
* Options for Web security.
|
|
1225
|
+
*/
|
|
1226
|
+
security?: SecurityConfig;
|
|
1227
|
+
/**
|
|
1228
|
+
* Options for build performance and runtime performance.
|
|
1229
|
+
*/
|
|
1230
|
+
performance?: PerformanceConfig;
|
|
1231
|
+
/**
|
|
1232
|
+
* Options for module federation.
|
|
1233
|
+
*/
|
|
1234
|
+
moduleFederation?: ModuleFederationConfig;
|
|
1235
|
+
/**
|
|
1236
|
+
* Configure Rsbuild plugins.
|
|
1237
|
+
*/
|
|
1238
|
+
plugins?: RsbuildPlugins;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* The Rsbuild config.
|
|
1242
|
+
* */
|
|
1243
|
+
export interface RsbuildConfig extends EnvironmentConfig {
|
|
1244
|
+
/**
|
|
1245
|
+
* Specify the Rsbuild build mode.
|
|
1246
|
+
*/
|
|
1247
|
+
mode?: RsbuildMode;
|
|
1248
|
+
/**
|
|
1249
|
+
* Specify the project root directory. Can be an absolute path, or a path relative to `process.cwd()`.
|
|
1250
|
+
* @default `process.cwd()`
|
|
1251
|
+
*/
|
|
1252
|
+
root?: string;
|
|
1253
|
+
/**
|
|
1254
|
+
* Options for local development.
|
|
1255
|
+
*/
|
|
1256
|
+
dev?: DevConfig;
|
|
1257
|
+
/**
|
|
1258
|
+
* Options for the Rsbuild Server,
|
|
1259
|
+
* will take effect during local development and preview.
|
|
1260
|
+
*/
|
|
1261
|
+
server?: ServerConfig;
|
|
1262
|
+
/**
|
|
1263
|
+
* Configure rsbuild config by environment.
|
|
1264
|
+
*/
|
|
1265
|
+
environments?: {
|
|
1266
|
+
[name: string]: EnvironmentConfig;
|
|
1267
|
+
};
|
|
1268
|
+
/**
|
|
1269
|
+
* Used to switch the bundler type.
|
|
1270
|
+
*/
|
|
1271
|
+
provider?: unknown;
|
|
1272
|
+
/**
|
|
1273
|
+
* @private
|
|
1274
|
+
*/
|
|
1275
|
+
_privateMeta?: RsbuildConfigMeta;
|
|
1276
|
+
}
|
|
1277
|
+
export type MergedEnvironmentConfig = {
|
|
1278
|
+
mode: RsbuildMode;
|
|
1279
|
+
root: string;
|
|
1280
|
+
dev: Pick<NormalizedDevConfig, 'hmr' | 'assetPrefix' | 'progressBar' | 'lazyCompilation' | 'writeToDisk'>;
|
|
1281
|
+
html: NormalizedHtmlConfig;
|
|
1282
|
+
tools: NormalizedToolsConfig;
|
|
1283
|
+
resolve: NormalizedResolveConfig;
|
|
1284
|
+
source: NormalizedSourceConfig;
|
|
1285
|
+
output: Omit<NormalizedOutputConfig, 'distPath'> & {
|
|
1286
|
+
distPath: Omit<Required<DistPathConfig>, 'jsAsync' | 'cssAsync'> & {
|
|
1287
|
+
jsAsync?: string;
|
|
1288
|
+
cssAsync?: string;
|
|
1289
|
+
};
|
|
1290
|
+
};
|
|
1291
|
+
plugins?: RsbuildPlugins;
|
|
1292
|
+
security: NormalizedSecurityConfig;
|
|
1293
|
+
performance: NormalizedPerformanceConfig;
|
|
1294
|
+
moduleFederation?: ModuleFederationConfig;
|
|
1295
|
+
};
|
|
1296
|
+
/**
|
|
1297
|
+
* The normalized Rsbuild environment config.
|
|
1298
|
+
*/
|
|
1299
|
+
export type NormalizedEnvironmentConfig = DeepReadonly<Omit<MergedEnvironmentConfig, 'dev'> & {
|
|
1300
|
+
dev: NormalizedDevConfig;
|
|
1301
|
+
server: NormalizedServerConfig;
|
|
1302
|
+
_privateMeta?: RsbuildConfigMeta;
|
|
1303
|
+
}>;
|
|
1304
|
+
export type NormalizedConfig = NormalizedEnvironmentConfig & {
|
|
1305
|
+
provider?: unknown;
|
|
1306
|
+
environments: {
|
|
1307
|
+
[name: string]: NormalizedEnvironmentConfig;
|
|
1308
|
+
};
|
|
1309
|
+
};
|