rspkify 0.0.0-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/bin/common/index.cjs +17658 -0
- package/bin/common/index.mjs +17623 -0
- package/bin/common/index2.cjs +633 -0
- package/bin/common/index2.mjs +630 -0
- package/bin/common/index3.cjs +17610 -0
- package/bin/common/index3.mjs +17579 -0
- package/bin/common/index4.cjs +2562 -0
- package/bin/common/index4.mjs +2560 -0
- package/bin/common/js-yaml.cjs +3871 -0
- package/bin/common/js-yaml.mjs +3855 -0
- package/bin/common/typescript.cjs +201850 -0
- package/bin/common/typescript.mjs +201848 -0
- package/bin/common/validation.cjs +100 -0
- package/bin/common/validation.mjs +98 -0
- package/bin/index.cjs +247 -0
- package/bin/index.d.ts +948 -0
- package/bin/index.mjs +228 -0
- package/bin/main.cjs +8519 -0
- package/bin/main.mjs +8510 -0
- package/package.json +77 -0
package/bin/index.d.ts
ADDED
|
@@ -0,0 +1,948 @@
|
|
|
1
|
+
import { RuleSetRule, Configuration, LibraryOptions, LoaderContext, WebpackPluginInstance } from '@rspack/core';
|
|
2
|
+
|
|
3
|
+
type RspackConfiguration = Configuration;
|
|
4
|
+
/** @deprecated 请使用 RspackConfiguration */
|
|
5
|
+
type WebpackConfiguration = Configuration;
|
|
6
|
+
type EntryOption = Configuration['entry'];
|
|
7
|
+
type OutputOption = Configuration['output'];
|
|
8
|
+
/**
|
|
9
|
+
* Rsify 缓存选项类型
|
|
10
|
+
*/
|
|
11
|
+
type CacheOption = boolean | 'memory' | 'filesystem' | Configuration['cache'];
|
|
12
|
+
/** Rspack 插件实例类型 */
|
|
13
|
+
type RspackPluginInstance = WebpackPluginInstance;
|
|
14
|
+
type BuildTargetsType = 'es5' | 'es6' | string | string[];
|
|
15
|
+
/**
|
|
16
|
+
* postcss-preset-env 插件选项类型
|
|
17
|
+
* 简化的类型定义,实际类型由 postcss-preset-env 包提供
|
|
18
|
+
*/
|
|
19
|
+
type PresetEnvOptions = {
|
|
20
|
+
browsers?: string | string[];
|
|
21
|
+
stage?: number;
|
|
22
|
+
features?: Record<string, false | {
|
|
23
|
+
features: boolean;
|
|
24
|
+
}>;
|
|
25
|
+
autoprefixer?: boolean | {
|
|
26
|
+
grid?: boolean;
|
|
27
|
+
flexbox?: string;
|
|
28
|
+
};
|
|
29
|
+
insertAfter?: string | string[];
|
|
30
|
+
preserve?: boolean | string;
|
|
31
|
+
[key: string]: any;
|
|
32
|
+
};
|
|
33
|
+
type CssModuleOptions = {
|
|
34
|
+
auto?: boolean | RegExp | ((resourcePath: string) => boolean);
|
|
35
|
+
mode?: 'local' | 'global' | 'pure' | 'icss' | ((resourcePath: string) => 'local' | 'global' | 'pure' | 'icss');
|
|
36
|
+
localIdentName?: string;
|
|
37
|
+
localIdentContext?: string;
|
|
38
|
+
localIdentHashSalt?: string;
|
|
39
|
+
localIdentHashFunction?: string;
|
|
40
|
+
localIdentHashDigest?: string;
|
|
41
|
+
localIdentRegExp?: string | RegExp;
|
|
42
|
+
getLocalIdent?: (context: LoaderContext<unknown>, localIdentName: string, localName: string) => string;
|
|
43
|
+
namedExport?: boolean;
|
|
44
|
+
exportGlobals?: boolean;
|
|
45
|
+
exportLocalsConvention?: 'as-is' | 'camel-case' | 'camel-case-only' | 'dashes' | 'dashes-only' | ((name: string) => string);
|
|
46
|
+
exportOnlyLocals?: boolean;
|
|
47
|
+
getJSON?: ({ resourcePath, imports, exports, replacements }: {
|
|
48
|
+
resourcePath: string;
|
|
49
|
+
imports: object[];
|
|
50
|
+
exports: object[];
|
|
51
|
+
replacements: object[];
|
|
52
|
+
}) => Promise<void> | void;
|
|
53
|
+
};
|
|
54
|
+
type BabelType = 'react' | 'react-ts' | 'react-lib' | 'react-ts-lib' | 'react-esm' | 'react-esm-lib' | 'preact' | 'preact-ts' | 'preact-lib' | 'preact-ts-lib' | 'preact-esm' | 'preact-esm-lib' | 'h5' | 'h5-ts' | 'h5-lib' | 'h5-ts-lib' | 'h5-esm' | 'h5-esm-lib' | 'node' | 'node-ts';
|
|
55
|
+
interface PxToRemOptions {
|
|
56
|
+
rootValue?: number;
|
|
57
|
+
unitPrecision?: number;
|
|
58
|
+
propList?: string[];
|
|
59
|
+
selectorBlackList?: (string | RegExp)[];
|
|
60
|
+
minPixelValue?: number;
|
|
61
|
+
mediaQuery?: boolean;
|
|
62
|
+
exclude?: string | RegExp | ((file: File) => boolean);
|
|
63
|
+
unit?: string;
|
|
64
|
+
}
|
|
65
|
+
type AssetOutType = {
|
|
66
|
+
emit?: boolean;
|
|
67
|
+
filename?: string;
|
|
68
|
+
publicPath?: string;
|
|
69
|
+
outputPath?: string;
|
|
70
|
+
};
|
|
71
|
+
type SvgOptions = {
|
|
72
|
+
symbolId?: string;
|
|
73
|
+
outputPath?: string;
|
|
74
|
+
publicPath?: string;
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* 图片选项类型(用于自动导入)
|
|
78
|
+
*/
|
|
79
|
+
type ImageOptionType = {
|
|
80
|
+
/** 是否启用自动导入 */
|
|
81
|
+
enable?: boolean;
|
|
82
|
+
/** 导入的文件后缀 */
|
|
83
|
+
extensions?: string[];
|
|
84
|
+
/** 导入路径 */
|
|
85
|
+
path?: string;
|
|
86
|
+
/** 是否递归搜索 */
|
|
87
|
+
recursive?: boolean;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* 资源规则类型(继承 AssetOutType 和 RuleItem)
|
|
91
|
+
* @see https://webpack.js.org/configuration/module/#rule
|
|
92
|
+
*/
|
|
93
|
+
type AssetsImageType = AssetOutType & RuleItem;
|
|
94
|
+
type AssetsVideoType = AssetOutType & RuleItem;
|
|
95
|
+
type AssetsFontType = AssetOutType & RuleItem;
|
|
96
|
+
type AssetsSvgType = {
|
|
97
|
+
/** 彩色 SVG 图标配置 */
|
|
98
|
+
colour?: boolean | (RuleItem & SvgOptions);
|
|
99
|
+
/** 纯色 SVG 图标配置 */
|
|
100
|
+
pure?: boolean | (RuleItem & SvgOptions);
|
|
101
|
+
} & RuleItem;
|
|
102
|
+
/**
|
|
103
|
+
* babel-preset-uniify 配置选项
|
|
104
|
+
* @see https://github.com/user/babel-preset-uniify
|
|
105
|
+
*/
|
|
106
|
+
type BabelPresetOptions = {
|
|
107
|
+
/** 项目环境类型(必填,由 BabelType 提供) */
|
|
108
|
+
type?: string;
|
|
109
|
+
/** 目标环境('es5' | 'es6' | 'node' | browserslist 格式) */
|
|
110
|
+
targets?: BuildTargetsType;
|
|
111
|
+
/** 模块类型('amd' | 'umd' | 'commonjs' | 'esm' | false | 'auto') */
|
|
112
|
+
modules?: 'amd' | 'umd' | 'commonjs' | 'esm' | false | 'auto';
|
|
113
|
+
/** React 版本('17' | '18') */
|
|
114
|
+
reactVersion?: '17' | '18';
|
|
115
|
+
/** JSX 导入源(React 17+,如 'react' | '@emotion/react' | '@mui/material') */
|
|
116
|
+
jsxImportSource?: string;
|
|
117
|
+
/** 是否为开发环境(默认根据 NODE_ENV 判断) */
|
|
118
|
+
development?: boolean;
|
|
119
|
+
/** 是否使用 transform-runtime 插件 */
|
|
120
|
+
useTransformRuntime?: boolean;
|
|
121
|
+
/** 自定义 import 配置 */
|
|
122
|
+
importConfig?: any;
|
|
123
|
+
/** 其他自定义选项 */
|
|
124
|
+
[key: string]: any;
|
|
125
|
+
};
|
|
126
|
+
type BabelBuildType = {
|
|
127
|
+
/** Babel 框架类型 */
|
|
128
|
+
type?: BabelType;
|
|
129
|
+
/** 是否使用 TypeScript(已废弃,请使用 type 中的 -ts 后缀) */
|
|
130
|
+
ts?: boolean;
|
|
131
|
+
/** babel-preset-uniify 配置选项 */
|
|
132
|
+
presetOptions?: BabelPresetOptions;
|
|
133
|
+
/** Babel loader 自定义选项 */
|
|
134
|
+
options?: any;
|
|
135
|
+
/** import 配置(保留兼容性) */
|
|
136
|
+
importConfig?: any;
|
|
137
|
+
} & RuleItem;
|
|
138
|
+
/** @deprecated 请使用 BabelBuildType */
|
|
139
|
+
type BableBuildType = BabelBuildType;
|
|
140
|
+
type BuildOptions = {
|
|
141
|
+
stats?: Configuration['stats'];
|
|
142
|
+
mode?: 'none' | 'development' | 'production';
|
|
143
|
+
analyze?: boolean;
|
|
144
|
+
devtool?: string | boolean;
|
|
145
|
+
target?: BuildTargetsType;
|
|
146
|
+
compile?: ['web'] | ['web', 'es5'] | ['node'];
|
|
147
|
+
babel?: BableBuildType;
|
|
148
|
+
/** 是否在重新构建时清理缓存(仅 filesystem 缓存有效) */
|
|
149
|
+
clearCacheOnRebuild?: boolean;
|
|
150
|
+
};
|
|
151
|
+
type RuleItem = RuleSetRule;
|
|
152
|
+
interface ExposesConfig {
|
|
153
|
+
import: string | string[];
|
|
154
|
+
name?: string;
|
|
155
|
+
}
|
|
156
|
+
interface ExposesObject {
|
|
157
|
+
[index: string]: string | ExposesConfig | string[];
|
|
158
|
+
}
|
|
159
|
+
interface RemotesConfig {
|
|
160
|
+
external: string | string[];
|
|
161
|
+
shareScope?: string;
|
|
162
|
+
}
|
|
163
|
+
interface RemotesObject {
|
|
164
|
+
[index: string]: string | RemotesConfig | string[];
|
|
165
|
+
}
|
|
166
|
+
interface SharedConfig {
|
|
167
|
+
eager?: boolean;
|
|
168
|
+
import?: string | false;
|
|
169
|
+
packageName?: string;
|
|
170
|
+
requiredVersion?: string | false;
|
|
171
|
+
shareKey?: string;
|
|
172
|
+
shareScope?: string;
|
|
173
|
+
singleton?: boolean;
|
|
174
|
+
strictVersion?: boolean;
|
|
175
|
+
version?: string | false;
|
|
176
|
+
}
|
|
177
|
+
interface SharedObject {
|
|
178
|
+
[index: string]: string | SharedConfig;
|
|
179
|
+
}
|
|
180
|
+
interface ModuleFederationPluginOptions {
|
|
181
|
+
exposes?: (string | ExposesObject)[] | ExposesObject;
|
|
182
|
+
filename?: string;
|
|
183
|
+
library?: LibraryOptions;
|
|
184
|
+
name?: string;
|
|
185
|
+
remoteType?: 'import' | 'var' | 'module' | 'assign' | 'this' | 'window' | 'self' | 'global' | 'commonjs' | 'commonjs2' | 'commonjs-module' | 'commonjs-static' | 'amd' | 'amd-require' | 'umd' | 'umd2' | 'jsonp' | 'system' | 'promise' | 'script' | 'node-commonjs';
|
|
186
|
+
remotes?: (string | RemotesObject)[] | RemotesObject;
|
|
187
|
+
runtime?: string | false;
|
|
188
|
+
shareScope?: string;
|
|
189
|
+
shared?: (string | SharedObject)[] | SharedObject;
|
|
190
|
+
}
|
|
191
|
+
type ModuleFederationOption = ModuleFederationPluginOptions;
|
|
192
|
+
/**
|
|
193
|
+
* 共享依赖配置模式
|
|
194
|
+
* - `true`: 自动从 peerDependencies 读取并设置 singleton
|
|
195
|
+
* - `string[]`: 指定共享的依赖名称数组
|
|
196
|
+
* - `SharedObject`: 完整的共享配置对象
|
|
197
|
+
* - `false`: 禁用自动共享
|
|
198
|
+
*/
|
|
199
|
+
type SharedDependenciesConfig = boolean | string[] | SharedObject | false;
|
|
200
|
+
/**
|
|
201
|
+
* 模块联邦简化配置选项
|
|
202
|
+
*/
|
|
203
|
+
interface ModuleFederationSimplifiedOptions {
|
|
204
|
+
/** 应用名称(默认从 package.json 读取) */
|
|
205
|
+
name?: string;
|
|
206
|
+
/** 远程模块配置 */
|
|
207
|
+
remotes?: ModuleFederationPluginOptions['remotes'];
|
|
208
|
+
/** 暴露的模块配置 */
|
|
209
|
+
exposes?: ModuleFederationPluginOptions['exposes'];
|
|
210
|
+
/** 共享依赖配置(默认: true - 自动从 peerDependencies 读取) */
|
|
211
|
+
shared?: SharedDependenciesConfig;
|
|
212
|
+
/** 输出文件名(默认: 'remoteEntry.js') */
|
|
213
|
+
filename?: string;
|
|
214
|
+
/** 运行时 chunk 名称 */
|
|
215
|
+
runtime?: string | false;
|
|
216
|
+
/** 共享作用域(默认: 'default') */
|
|
217
|
+
shareScope?: string;
|
|
218
|
+
/** 库配置 */
|
|
219
|
+
library?: LibraryOptions;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* CDN 公共路径类型
|
|
223
|
+
*/
|
|
224
|
+
type PublicPathType = string | ((val: string) => string);
|
|
225
|
+
/**
|
|
226
|
+
* CDN 资源项类型
|
|
227
|
+
*/
|
|
228
|
+
interface CdnResourceItem {
|
|
229
|
+
/** 资源路径 */
|
|
230
|
+
path: string;
|
|
231
|
+
/** 自定义 publicPath */
|
|
232
|
+
publicPath?: PublicPathType;
|
|
233
|
+
/** 注入位置 */
|
|
234
|
+
inject?: 'head' | 'body';
|
|
235
|
+
/** 位置(开始或结束) */
|
|
236
|
+
position?: 'start' | 'end';
|
|
237
|
+
/** 异步加载 */
|
|
238
|
+
async?: boolean;
|
|
239
|
+
/** 延迟加载 */
|
|
240
|
+
defer?: boolean;
|
|
241
|
+
/** 跨域设置 */
|
|
242
|
+
crossorigin?: 'anonymous' | 'use-credentials';
|
|
243
|
+
/** 完整性校验 */
|
|
244
|
+
integrity?: string;
|
|
245
|
+
/** 不支持模块的回退 */
|
|
246
|
+
nomodule?: boolean;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* CDN 上下文类型
|
|
250
|
+
*/
|
|
251
|
+
interface CdnContext {
|
|
252
|
+
headTags: any[];
|
|
253
|
+
bodyTags: any[];
|
|
254
|
+
compilation?: any;
|
|
255
|
+
compiler?: any;
|
|
256
|
+
env?: Record<string, any>;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* CDN 配置
|
|
260
|
+
*/
|
|
261
|
+
interface CdnConfig {
|
|
262
|
+
/** CDN 公共路径前缀 */
|
|
263
|
+
publicPath?: PublicPathType;
|
|
264
|
+
/** 默认注入位置 */
|
|
265
|
+
inject?: 'head' | 'body';
|
|
266
|
+
/** 资源列表 */
|
|
267
|
+
resources?: (CdnResourceItem | string)[] | ((context: CdnContext) => (CdnResourceItem | string)[]);
|
|
268
|
+
}
|
|
269
|
+
/**
|
|
270
|
+
* SpyPage 监控选项
|
|
271
|
+
*/
|
|
272
|
+
interface SpyPageOptions {
|
|
273
|
+
version?: string;
|
|
274
|
+
enablePerformance?: boolean;
|
|
275
|
+
enableError?: boolean;
|
|
276
|
+
enableUserBehavior?: boolean;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* 自定义脚本项类型
|
|
280
|
+
*/
|
|
281
|
+
type CustomScriptItemType = string | {
|
|
282
|
+
/** 脚本类型 */
|
|
283
|
+
type: 'external' | 'inline';
|
|
284
|
+
/** 内联脚本内容 */
|
|
285
|
+
content?: string;
|
|
286
|
+
/** 外部脚本地址 */
|
|
287
|
+
src?: string;
|
|
288
|
+
/** 注入位置 */
|
|
289
|
+
inject?: 'head' | 'body';
|
|
290
|
+
/** 位置 */
|
|
291
|
+
position?: 'start' | 'end';
|
|
292
|
+
/** 异步加载 */
|
|
293
|
+
async?: boolean;
|
|
294
|
+
/** 延迟加载 */
|
|
295
|
+
defer?: boolean;
|
|
296
|
+
/** 跨域设置 */
|
|
297
|
+
crossorigin?: 'anonymous' | 'use-credentials';
|
|
298
|
+
/** 完整性校验 */
|
|
299
|
+
integrity?: string;
|
|
300
|
+
/** 不支持模块的回退 */
|
|
301
|
+
nomodule?: boolean;
|
|
302
|
+
};
|
|
303
|
+
/**
|
|
304
|
+
* 脚本注入配置
|
|
305
|
+
*/
|
|
306
|
+
interface ScriptsConfig {
|
|
307
|
+
/** QQ SDK */
|
|
308
|
+
qq?: boolean | string;
|
|
309
|
+
/** 微信 SDK */
|
|
310
|
+
weixin?: boolean | string;
|
|
311
|
+
/** SpyPage 监控 */
|
|
312
|
+
spyPage?: boolean | SpyPageOptions;
|
|
313
|
+
/** VSCode 集成 */
|
|
314
|
+
vscode?: boolean | string;
|
|
315
|
+
/** 自定义脚本 */
|
|
316
|
+
custom?: CustomScriptItemType[];
|
|
317
|
+
}
|
|
318
|
+
/**
|
|
319
|
+
* Adapter 配置
|
|
320
|
+
*/
|
|
321
|
+
interface AdapterConfig {
|
|
322
|
+
type: 'client' | 'h5' | 'h5-landscape' | 'web';
|
|
323
|
+
options?: {
|
|
324
|
+
rootValue?: number;
|
|
325
|
+
[key: string]: any;
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* HTML 配置选项
|
|
330
|
+
*/
|
|
331
|
+
interface HtmlOptions {
|
|
332
|
+
/** 页面标题 */
|
|
333
|
+
title?: string;
|
|
334
|
+
/** 是否压缩 */
|
|
335
|
+
minify?: boolean;
|
|
336
|
+
/** 模板路径 */
|
|
337
|
+
template?: string;
|
|
338
|
+
/** 输出文件名 */
|
|
339
|
+
filename?: string | ((name: string) => string);
|
|
340
|
+
/** 屏幕适配配置 */
|
|
341
|
+
adapter?: 'h5' | 'h5-landscape' | 'client' | 'web' | AdapterConfig;
|
|
342
|
+
/** CDN 配置 */
|
|
343
|
+
cdn?: CdnConfig | false | null;
|
|
344
|
+
/** 脚本注入配置 */
|
|
345
|
+
scripts?: ScriptsConfig | false | null;
|
|
346
|
+
/** HTML 块 */
|
|
347
|
+
chunks?: string | string[] | ((dirName: string, path: string) => string | string[]);
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* 优化配置选项(简化版)
|
|
351
|
+
*/
|
|
352
|
+
interface OptimizationOptions {
|
|
353
|
+
/** 是否压缩代码 */
|
|
354
|
+
minimize?: boolean;
|
|
355
|
+
/** 代码分割配置 */
|
|
356
|
+
splitChunks?: boolean | {
|
|
357
|
+
chunks?: 'all' | 'async' | 'initial';
|
|
358
|
+
maxSize?: number;
|
|
359
|
+
cacheGroups?: any;
|
|
360
|
+
};
|
|
361
|
+
/** 运行时代码分割 */
|
|
362
|
+
runtimeChunk?: boolean | 'single' | 'multiple';
|
|
363
|
+
}
|
|
364
|
+
/**
|
|
365
|
+
* Bundle Analyzer 配置选项
|
|
366
|
+
* 基于 webpack-bundle-analyzer 官方文档
|
|
367
|
+
* @see https://github.com/webpack/webpack-bundle-analyzer
|
|
368
|
+
*/
|
|
369
|
+
interface AnalyzerOptions {
|
|
370
|
+
/** 是否启用分析(Webify 自定义选项,不在官方 API 中) */
|
|
371
|
+
enabled?: boolean;
|
|
372
|
+
/** 分析模式(默认:server) */
|
|
373
|
+
analyzerMode?: 'server' | 'static' | 'json' | 'disabled';
|
|
374
|
+
/** server 模式下的主机(默认:127.0.0.1) */
|
|
375
|
+
analyzerHost?: string;
|
|
376
|
+
/** server 模式下的端口,'auto' 表示自动分配(默认:8888) */
|
|
377
|
+
analyzerPort?: number | 'auto';
|
|
378
|
+
/** 自定义 server 模式下控制台打印的 URL */
|
|
379
|
+
analyzerUrl?: (listenHost: string, boundAddress: string) => string;
|
|
380
|
+
/** 是否自动在浏览器中打开报告(默认:true) */
|
|
381
|
+
openAnalyzer?: boolean;
|
|
382
|
+
/** static 模式下的报告文件名(默认:report.html) */
|
|
383
|
+
reportFilename?: string;
|
|
384
|
+
/** HTML 报告标题(默认:当前日期时间) */
|
|
385
|
+
reportTitle?: string | (() => string);
|
|
386
|
+
/** 报告中默认显示的模块大小类型(默认:parsed) */
|
|
387
|
+
defaultSizes?: 'stat' | 'parsed' | 'gzip' | 'brotli' | 'zstd';
|
|
388
|
+
/** 计算压缩大小时使用的算法(默认:gzip) */
|
|
389
|
+
compressionAlgorithm?: 'gzip' | 'brotli' | 'zstd';
|
|
390
|
+
/** 是否生成 webpack stats JSON 文件(默认:false) */
|
|
391
|
+
generateStatsFile?: boolean;
|
|
392
|
+
/** stats 文件名(默认:stats.json) */
|
|
393
|
+
statsFilename?: string;
|
|
394
|
+
/** 传递给 stats.toJson() 的选项(默认:null) */
|
|
395
|
+
statsOptions?: null | Record<string, any>;
|
|
396
|
+
/**
|
|
397
|
+
* 排除特定资源的模式(默认:null)
|
|
398
|
+
* 可以是字符串、RegExp、函数或数组
|
|
399
|
+
*/
|
|
400
|
+
excludeAssets?: string | RegExp | ((assetName: string) => boolean) | Array<string | RegExp | ((assetName: string) => boolean)>;
|
|
401
|
+
/** 控制台日志级别(默认:info) */
|
|
402
|
+
logLevel?: 'info' | 'warn' | 'error' | 'silent' | 'debug';
|
|
403
|
+
}
|
|
404
|
+
/**
|
|
405
|
+
* 插件配置选项(简化版)
|
|
406
|
+
*/
|
|
407
|
+
interface PluginOptions {
|
|
408
|
+
/** BundleAnalyzer 配置(分析包体积) */
|
|
409
|
+
analyzer?: boolean | AnalyzerOptions;
|
|
410
|
+
/** IgnorePlugin 配置(忽略模块) */
|
|
411
|
+
ignore?: string | RegExp | (string | RegExp)[];
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Copy 插件配置模式类型
|
|
415
|
+
* 基于 Rspack 内置 CopyRspackPlugin
|
|
416
|
+
* @see https://rspack.dev/plugins/rspack/copy-rspack-plugin
|
|
417
|
+
*/
|
|
418
|
+
type CopyPattern = string | {
|
|
419
|
+
/** 要复制的源文件或目录(支持通配符,必填) */
|
|
420
|
+
from: string;
|
|
421
|
+
/** 输出目标路径(相对 webpack output.path) */
|
|
422
|
+
to?: string;
|
|
423
|
+
/** from 路径的解析上下文 */
|
|
424
|
+
context?: string;
|
|
425
|
+
/** 传递给 glob 库的选项 */
|
|
426
|
+
globOptions?: {
|
|
427
|
+
/** 忽略的文件模式 */
|
|
428
|
+
ignore?: string | string[];
|
|
429
|
+
dot?: boolean;
|
|
430
|
+
[key: string]: any;
|
|
431
|
+
};
|
|
432
|
+
/** 过滤函数 (absolutePath) => boolean */
|
|
433
|
+
filter?: (absolutePath: string) => boolean;
|
|
434
|
+
/** 强制 to 的类型 */
|
|
435
|
+
toType?: 'dir' | 'file' | 'template';
|
|
436
|
+
/** 优先级,允许规则覆盖其他规则 */
|
|
437
|
+
priority?: number;
|
|
438
|
+
/** 修改文件信息对象 */
|
|
439
|
+
info?: Record<string, any> | ((file: Record<string, any>) => Record<string, any>);
|
|
440
|
+
/** 在复制前修改文件内容 */
|
|
441
|
+
transform?: ((content: string, absoluteFrom: string) => string | Promise<string>) | {
|
|
442
|
+
transformer: (content: string, absoluteFrom: string) => string | Promise<string>;
|
|
443
|
+
cache?: boolean;
|
|
444
|
+
};
|
|
445
|
+
/** 修改所有匹配的文件内容(仅在 from 为目录时有效) */
|
|
446
|
+
transformAll?: (files: {
|
|
447
|
+
filename: string;
|
|
448
|
+
content: string;
|
|
449
|
+
}[]) => Record<string, any>;
|
|
450
|
+
/** 如果为 true,当 from 匹配不到文件时不会报错 */
|
|
451
|
+
noErrorOnMissing?: boolean;
|
|
452
|
+
};
|
|
453
|
+
/**
|
|
454
|
+
* 资源配置选项(扁平化版)
|
|
455
|
+
* @see https://webpack.js.org/guides/asset-modules/
|
|
456
|
+
*/
|
|
457
|
+
type ImageOptions = AssetOutType & {
|
|
458
|
+
maxSize?: number;
|
|
459
|
+
limit?: number;
|
|
460
|
+
};
|
|
461
|
+
type VideoOptions = AssetOutType & {
|
|
462
|
+
maxSize?: number;
|
|
463
|
+
limit?: number;
|
|
464
|
+
};
|
|
465
|
+
type FontOptions = AssetOutType & {
|
|
466
|
+
maxSize?: number;
|
|
467
|
+
limit?: number;
|
|
468
|
+
};
|
|
469
|
+
type AssetsOptions = {
|
|
470
|
+
/** 自动导入图片 */
|
|
471
|
+
autoImport?: ImageOptionType;
|
|
472
|
+
html?: any;
|
|
473
|
+
image?: boolean | ImageOptions;
|
|
474
|
+
video?: boolean | VideoOptions;
|
|
475
|
+
font?: boolean | FontOptions;
|
|
476
|
+
svg?: {
|
|
477
|
+
/** 彩色 SVG 图标配置(向后兼容 sprite) */
|
|
478
|
+
colour?: boolean | (RuleItem & SvgOptions);
|
|
479
|
+
sprite?: boolean | (RuleItem & SvgOptions);
|
|
480
|
+
/** 纯色 SVG 图标配置 */
|
|
481
|
+
pure?: boolean | (RuleItem & SvgOptions);
|
|
482
|
+
/** SVG URL Loader 配置 */
|
|
483
|
+
url?: boolean | AssetOutType;
|
|
484
|
+
};
|
|
485
|
+
};
|
|
486
|
+
/**
|
|
487
|
+
* 资源配置类型(完整版)
|
|
488
|
+
* @see https://webpack.js.org/configuration/module/
|
|
489
|
+
*/
|
|
490
|
+
type AssetsType = {
|
|
491
|
+
/** 自动导入图片 */
|
|
492
|
+
autoImport?: ImageOptionType;
|
|
493
|
+
/** HTML 资源配置 */
|
|
494
|
+
html?: any;
|
|
495
|
+
/** 图片资源配置 */
|
|
496
|
+
image?: boolean | AssetsImageType;
|
|
497
|
+
/** 视频资源配置 */
|
|
498
|
+
video?: boolean | AssetsVideoType;
|
|
499
|
+
/** 字体资源配置 */
|
|
500
|
+
font?: boolean | AssetsFontType;
|
|
501
|
+
/** SVG 资源配置 */
|
|
502
|
+
svg?: AssetsSvgType;
|
|
503
|
+
};
|
|
504
|
+
interface DevOption {
|
|
505
|
+
/** 开发服务器端口 */
|
|
506
|
+
port?: string | number;
|
|
507
|
+
/** 开发服务器主机 */
|
|
508
|
+
host?: string;
|
|
509
|
+
/** 是否自动打开浏览器 */
|
|
510
|
+
open?: boolean | string;
|
|
511
|
+
/** 是否启用热更新 */
|
|
512
|
+
hot?: boolean | 'only';
|
|
513
|
+
/** 是否启用 gzip 压缩 */
|
|
514
|
+
compress?: boolean;
|
|
515
|
+
/** 是否启用 History API 回退 */
|
|
516
|
+
historyApiFallback?: boolean | Record<string, any>;
|
|
517
|
+
/** 客户端配置 */
|
|
518
|
+
client?: Record<string, any> | boolean;
|
|
519
|
+
/** 代理配置 */
|
|
520
|
+
proxy?: Record<string, any> | Record<string, any>[];
|
|
521
|
+
/** 代理目标(简化配置) */
|
|
522
|
+
proxyTarget?: string | {
|
|
523
|
+
context: string;
|
|
524
|
+
target: string;
|
|
525
|
+
} | {
|
|
526
|
+
context: string;
|
|
527
|
+
target: string;
|
|
528
|
+
}[];
|
|
529
|
+
/** 静态文件配置 */
|
|
530
|
+
static?: string | boolean | Record<string, any> | (string | Record<string, any>)[];
|
|
531
|
+
/** 允许的主机 */
|
|
532
|
+
allowedHosts?: 'all' | 'auto' | string[];
|
|
533
|
+
/** 请求头配置 */
|
|
534
|
+
headers?: Record<string, string> | ((req: any, res: any, context: any) => Record<string, string>);
|
|
535
|
+
/** HTTPS 配置 */
|
|
536
|
+
https?: boolean | Record<string, any>;
|
|
537
|
+
/** 服务器配置 */
|
|
538
|
+
server?: string | Record<string, any>;
|
|
539
|
+
/** 其他 webpack-dev-server 配置 */
|
|
540
|
+
[key: string]: any;
|
|
541
|
+
}
|
|
542
|
+
/**
|
|
543
|
+
* 通用样式配置选项(CSS 和 SCSS 共用)
|
|
544
|
+
*/
|
|
545
|
+
interface BaseStyleOptions {
|
|
546
|
+
/**
|
|
547
|
+
* 是否启用 CSS Modules
|
|
548
|
+
*
|
|
549
|
+
* 支持多种格式:
|
|
550
|
+
* - `boolean`: true 启用,false 禁用
|
|
551
|
+
* - `RegExp`: 正则匹配的文件使用 CSS Modules
|
|
552
|
+
* - `Function`: 函数返回 true 时使用 CSS Modules
|
|
553
|
+
* - `CssModuleOptions`: CSS Loader 配置对象(支持 auto 等选项)
|
|
554
|
+
* - `string[]`: 字符串数组,指定路径下的文件使用 CSS Modules
|
|
555
|
+
* - `CssModuleItem[]`: 混合配置数组,可指定哪些使用/不使用 CSS Modules
|
|
556
|
+
*/
|
|
557
|
+
modules?: boolean | RegExp | ((resourcePath: string) => boolean) | CssModuleOptions | string[] | CssModuleItem[];
|
|
558
|
+
/** 是否压缩 CSS */
|
|
559
|
+
minimize?: boolean;
|
|
560
|
+
/** 是否提取为单独文件 */
|
|
561
|
+
extract?: boolean;
|
|
562
|
+
/** 文件名 */
|
|
563
|
+
filename?: string;
|
|
564
|
+
/** chunk 文件名 */
|
|
565
|
+
chunkFilename?: string;
|
|
566
|
+
/** 附加数据(如全局变量) */
|
|
567
|
+
additionalData?: string | ((content: string, filename: string) => string);
|
|
568
|
+
/** 是否内联到 JS(开发模式) */
|
|
569
|
+
inline?: boolean;
|
|
570
|
+
/** 是否生成 source map */
|
|
571
|
+
sourceMap?: boolean;
|
|
572
|
+
/** webpack 规则排除 */
|
|
573
|
+
exclude?: RuleSetRule['exclude'];
|
|
574
|
+
/** webpack 规则选项 */
|
|
575
|
+
innerRule?: Partial<RuleSetRule>;
|
|
576
|
+
/** 是否使用 ES Module */
|
|
577
|
+
esModule?: boolean;
|
|
578
|
+
/** CSS Loader 的 publicPath */
|
|
579
|
+
publicPath?: string;
|
|
580
|
+
/** CSS Loader 的 emit 选项 */
|
|
581
|
+
emit?: boolean;
|
|
582
|
+
/** PostCSS 配置 */
|
|
583
|
+
postcss?: {
|
|
584
|
+
presetEnv?: PresetEnvOptions;
|
|
585
|
+
pxtoRem?: PxToRemOptions;
|
|
586
|
+
};
|
|
587
|
+
}
|
|
588
|
+
/**
|
|
589
|
+
* CSS Modules 配置项(用于数组格式)
|
|
590
|
+
*/
|
|
591
|
+
interface CssModuleItem {
|
|
592
|
+
/** CSS Modules 配置 */
|
|
593
|
+
module?: boolean | CssModuleOptions;
|
|
594
|
+
/** 本地类名前缀 */
|
|
595
|
+
localName?: string;
|
|
596
|
+
/** 匹配规则(支持正则和函数) */
|
|
597
|
+
test?: RegExp | ((path: string) => boolean);
|
|
598
|
+
/** 额外的数据 */
|
|
599
|
+
additionalData?: string;
|
|
600
|
+
[key: string]: any;
|
|
601
|
+
}
|
|
602
|
+
/**
|
|
603
|
+
* SCSS 配置选项(继承 BaseStyleOptions)
|
|
604
|
+
* 继承所有 CSS 配置选项,并添加 SCSS 特有选项
|
|
605
|
+
*/
|
|
606
|
+
interface ScssOptions extends BaseStyleOptions {
|
|
607
|
+
/** SCSS 特有:输出风格 */
|
|
608
|
+
outputStyle?: 'expanded' | 'compressed' | 'nested' | 'compact';
|
|
609
|
+
/** SCSS 特有:包含路径 */
|
|
610
|
+
includePaths?: string[];
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* CSS 配置选项(继承 BaseStyleOptions)
|
|
614
|
+
*/
|
|
615
|
+
interface CssOptions extends BaseStyleOptions {
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* PostCSS 配置选项(扁平化版)
|
|
619
|
+
*/
|
|
620
|
+
interface PostcssOptions {
|
|
621
|
+
/** postcss-preset-env 配置 */
|
|
622
|
+
presetEnv?: PresetEnvOptions;
|
|
623
|
+
/** postcss-pxtorem 配置 */
|
|
624
|
+
pxtoRem?: PxToRemOptions;
|
|
625
|
+
/** rootValue(用于屏幕适配) */
|
|
626
|
+
rootValue?: number;
|
|
627
|
+
}
|
|
628
|
+
/**
|
|
629
|
+
* 样式配置选项(扁平化版)
|
|
630
|
+
*/
|
|
631
|
+
interface StyleOptions {
|
|
632
|
+
/** CSS 配置 */
|
|
633
|
+
css?: CssOptions;
|
|
634
|
+
/** SCSS 配置 */
|
|
635
|
+
scss?: ScssOptions;
|
|
636
|
+
/** PostCSS 配置 */
|
|
637
|
+
postcss?: PostcssOptions;
|
|
638
|
+
/** 样式文件名(全局默认值) */
|
|
639
|
+
filename?: string;
|
|
640
|
+
/** chunk 文件名(全局默认值) */
|
|
641
|
+
chunkFilename?: string;
|
|
642
|
+
/** 是否内联(全局默认值) */
|
|
643
|
+
inline?: boolean;
|
|
644
|
+
/** source map(全局默认值) */
|
|
645
|
+
sourceMap?: boolean;
|
|
646
|
+
}
|
|
647
|
+
/**
|
|
648
|
+
* Webify 命令行配置参数
|
|
649
|
+
* 用于传递 CLI 参数到配置函数
|
|
650
|
+
*/
|
|
651
|
+
interface WebifyCommandLineConfigure {
|
|
652
|
+
/** 是否启动开发服务 */
|
|
653
|
+
service: boolean;
|
|
654
|
+
/** 配置文件路径 */
|
|
655
|
+
config?: string;
|
|
656
|
+
/** 开发服务器端口 */
|
|
657
|
+
port?: number;
|
|
658
|
+
/** 开发服务器主机 */
|
|
659
|
+
host?: string;
|
|
660
|
+
/** 是否自动打开浏览器 */
|
|
661
|
+
open?: boolean;
|
|
662
|
+
/** 构建类型 */
|
|
663
|
+
type?: string;
|
|
664
|
+
/** 构建模式 */
|
|
665
|
+
mode?: 'development' | 'production' | 'none';
|
|
666
|
+
/** 是否启用构建分析 */
|
|
667
|
+
analyze?: boolean;
|
|
668
|
+
/** 是否生成构建报告 */
|
|
669
|
+
report?: boolean;
|
|
670
|
+
/** 是否显示详细信息 */
|
|
671
|
+
verbose?: boolean;
|
|
672
|
+
}
|
|
673
|
+
/**
|
|
674
|
+
* Webify 命令行参数
|
|
675
|
+
* 与 WebifyCommandLineConfigure 完全一致,保留为类型别名以兼容旧代码
|
|
676
|
+
*/
|
|
677
|
+
type WebifyParams = WebifyCommandLineConfigure;
|
|
678
|
+
/**
|
|
679
|
+
* Webify 钩子函数
|
|
680
|
+
*/
|
|
681
|
+
interface WebifyHooks {
|
|
682
|
+
/** 构建前钩子 */
|
|
683
|
+
beforeBuild?: (config: any) => void | Promise<void>;
|
|
684
|
+
/** 构建后钩子 */
|
|
685
|
+
afterBuild?: (stats: any) => void | Promise<void>;
|
|
686
|
+
/** 错误处理钩子 */
|
|
687
|
+
onError?: (error: Error) => void | Promise<void>;
|
|
688
|
+
}
|
|
689
|
+
interface WebifyConfigOption {
|
|
690
|
+
appType?: 'spa' | 'mpa';
|
|
691
|
+
framework?: 'h5' | 'react' | 'preact' | 'vue';
|
|
692
|
+
entry?: EntryOption;
|
|
693
|
+
output?: OutputOption | (() => OutputOption);
|
|
694
|
+
build?: BuildOptions;
|
|
695
|
+
cache?: CacheOption;
|
|
696
|
+
moduleFederation?: Partial<ModuleFederationOption>;
|
|
697
|
+
/** 优化配置(支持简化版或完整 rspack 配置) */
|
|
698
|
+
optimization?: boolean | OptimizationOptions | Configuration['optimization'];
|
|
699
|
+
alias?: Record<string, string>;
|
|
700
|
+
resolve?: Configuration['resolve'] | (() => Configuration['resolve']);
|
|
701
|
+
/** 开发服务器配置(统一命名) */
|
|
702
|
+
dev?: DevOption;
|
|
703
|
+
html?: HtmlOptions;
|
|
704
|
+
/** 样式配置(扁平化) */
|
|
705
|
+
style?: StyleOptions;
|
|
706
|
+
/** 资源配置(扁平化) */
|
|
707
|
+
assets?: AssetsOptions;
|
|
708
|
+
/** ProvidePlugin 配置(替代 global) */
|
|
709
|
+
provide?: {
|
|
710
|
+
/** 运行时模块列表(保留兼容性) */
|
|
711
|
+
runtime?: string[];
|
|
712
|
+
/** 自定义 ProvidePlugin 映射 */
|
|
713
|
+
modules?: Record<string, string | string[]>;
|
|
714
|
+
};
|
|
715
|
+
/** CopyPlugin 配置(复制静态资源) */
|
|
716
|
+
copy?: CopyPattern | CopyPattern[];
|
|
717
|
+
define?: Record<string, string>;
|
|
718
|
+
/** 扩展规则(自定义 rspack rules) */
|
|
719
|
+
rules?: RuleSetRule | RuleSetRule[];
|
|
720
|
+
/** 扩展插件(自定义 rspack plugins) */
|
|
721
|
+
plugins?: RspackPluginInstance | RspackPluginInstance[];
|
|
722
|
+
/** 插件配置(简化版) */
|
|
723
|
+
pluginOptions?: PluginOptions;
|
|
724
|
+
/** CSS-in-TypeScript 静态编译配置 */
|
|
725
|
+
cssInTS?: boolean | {
|
|
726
|
+
/** 类名生成规则 */
|
|
727
|
+
generateClassName?: (exportName: string, filePath: string, hash: string) => string;
|
|
728
|
+
/** CSS 输出策略: 'per-file' 每个 .style.ts 生成一个 .css | 'single-bundle' 合并为单个 CSS */
|
|
729
|
+
outputCSS?: 'per-file' | 'single-bundle';
|
|
730
|
+
/** 是否为开发模式(自动检测) */
|
|
731
|
+
devMode?: boolean;
|
|
732
|
+
/** 样式文件匹配模式,默认 /\.style\.ts$/ */
|
|
733
|
+
test?: RegExp;
|
|
734
|
+
/** 是否启用 source map */
|
|
735
|
+
sourceMap?: boolean;
|
|
736
|
+
};
|
|
737
|
+
/** 高级 Rspack 配置 */
|
|
738
|
+
rspack?: {
|
|
739
|
+
/** 在最终配置前执行(可修改配置) */
|
|
740
|
+
before?: (config: Configuration) => Configuration;
|
|
741
|
+
/** 在最终配置后执行(可修改配置) */
|
|
742
|
+
after?: (config: Configuration) => Configuration;
|
|
743
|
+
/** 直接替换配置项 */
|
|
744
|
+
replace?: {
|
|
745
|
+
[key in keyof Configuration]?: Configuration[key];
|
|
746
|
+
};
|
|
747
|
+
};
|
|
748
|
+
/** @deprecated 请使用 rspack 字段 */
|
|
749
|
+
webpack?: {
|
|
750
|
+
before?: (config: Configuration) => Configuration;
|
|
751
|
+
after?: (config: Configuration) => Configuration;
|
|
752
|
+
replace?: {
|
|
753
|
+
[key in keyof Configuration]?: Configuration[key];
|
|
754
|
+
};
|
|
755
|
+
};
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
declare const rspackConfigPlugin: (useConfig: WebifyConfigOption, userParams: WebifyCommandLineConfigure, configDir?: string) => {
|
|
759
|
+
devConfig: RspackConfiguration;
|
|
760
|
+
proConfig: RspackConfiguration;
|
|
761
|
+
};
|
|
762
|
+
/** @deprecated 请使用 rspackConfigPlugin */
|
|
763
|
+
declare const webpckConfigPlugin: (useConfig: WebifyConfigOption, userParams: WebifyCommandLineConfigure, configDir?: string) => {
|
|
764
|
+
devConfig: RspackConfiguration;
|
|
765
|
+
proConfig: RspackConfiguration;
|
|
766
|
+
};
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* 创建远程模块配置
|
|
770
|
+
*
|
|
771
|
+
* @example
|
|
772
|
+
* const remotes = createRemotes({
|
|
773
|
+
* app1: 'http://localhost:3001/remoteEntry.js',
|
|
774
|
+
* app2: 'http://localhost:3002/remoteEntry.js'
|
|
775
|
+
* })
|
|
776
|
+
* // => { app1: 'app1@http://localhost:3001/remoteEntry.js', ... }
|
|
777
|
+
*/
|
|
778
|
+
declare function createRemotes(remotes: Record<string, string>): Record<string, string>;
|
|
779
|
+
/**
|
|
780
|
+
* 创建暴露模块配置
|
|
781
|
+
*
|
|
782
|
+
* @example
|
|
783
|
+
* const exposes = createExposes({
|
|
784
|
+
* './Button': './src/components/Button',
|
|
785
|
+
* './utils': './src/utils/index'
|
|
786
|
+
* })
|
|
787
|
+
*/
|
|
788
|
+
declare function createExposes(exposes: Record<string, string>): Record<string, string>;
|
|
789
|
+
/**
|
|
790
|
+
* 创建共享依赖配置
|
|
791
|
+
*
|
|
792
|
+
* @example
|
|
793
|
+
* const shared = createShared({
|
|
794
|
+
* react: { singleton: true },
|
|
795
|
+
* 'react-dom': { singleton: true }
|
|
796
|
+
* })
|
|
797
|
+
*/
|
|
798
|
+
declare function createShared(shared: Record<string, SharedConfig>): SharedObject;
|
|
799
|
+
/**
|
|
800
|
+
* 创建常用的 React 共享依赖配置
|
|
801
|
+
*
|
|
802
|
+
* @param version - React 版本,默认 '*'
|
|
803
|
+
* @param options - 配置选项
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
* const shared = createReactShared('^18.0.0')
|
|
807
|
+
*/
|
|
808
|
+
declare function createReactShared(version?: string, options?: {
|
|
809
|
+
/** 是否单例 */
|
|
810
|
+
singleton?: boolean;
|
|
811
|
+
/** 是否严格版本检查 */
|
|
812
|
+
strictVersion?: boolean;
|
|
813
|
+
/** 是否 eager 加载 */
|
|
814
|
+
eager?: boolean;
|
|
815
|
+
}): SharedObject;
|
|
816
|
+
/**
|
|
817
|
+
* 创建常用的 Vue 共享依赖配置
|
|
818
|
+
*
|
|
819
|
+
* @param version - Vue 版本,默认 '*'
|
|
820
|
+
* @param options - 配置选项
|
|
821
|
+
*
|
|
822
|
+
* @example
|
|
823
|
+
* const shared = createVueShared('^3.0.0')
|
|
824
|
+
*/
|
|
825
|
+
declare function createVueShared(version?: string, options?: {
|
|
826
|
+
singleton?: boolean;
|
|
827
|
+
strictVersion?: boolean;
|
|
828
|
+
eager?: boolean;
|
|
829
|
+
}): SharedObject;
|
|
830
|
+
/**
|
|
831
|
+
* 从环境变量创建远程模块配置
|
|
832
|
+
*
|
|
833
|
+
* @example
|
|
834
|
+
* // .env 文件
|
|
835
|
+
* REMOTE_APP1=http://localhost:3001/remoteEntry.js
|
|
836
|
+
* REMOTE_APP2=http://localhost:3002/remoteEntry.js
|
|
837
|
+
*
|
|
838
|
+
* // 使用
|
|
839
|
+
* const remotes = createRemotesFromEnv('REMOTE_')
|
|
840
|
+
*/
|
|
841
|
+
declare function createRemotesFromEnv(prefix?: string): Record<string, string>;
|
|
842
|
+
/**
|
|
843
|
+
* 合并多个共享依赖配置
|
|
844
|
+
*
|
|
845
|
+
* @description
|
|
846
|
+
* 当同一个依赖在多个配置中出现时,后面的配置会覆盖前面的
|
|
847
|
+
*
|
|
848
|
+
* @example
|
|
849
|
+
* const shared = mergeShared(
|
|
850
|
+
* createReactShared('^18.0.0'),
|
|
851
|
+
* { lodash: { singleton: false } }
|
|
852
|
+
* )
|
|
853
|
+
*/
|
|
854
|
+
declare function mergeShared(...sharedObjects: (SharedObject | undefined)[]): SharedObject;
|
|
855
|
+
/**
|
|
856
|
+
* 快速创建共享依赖配置(简化版)
|
|
857
|
+
*
|
|
858
|
+
* @description
|
|
859
|
+
* 快速创建单例模式的共享依赖配置
|
|
860
|
+
*
|
|
861
|
+
* @example
|
|
862
|
+
* const shared = createQuickShared(['react', 'react-dom', 'lodash'])
|
|
863
|
+
* // => {
|
|
864
|
+
* // react: { singleton: true, requiredVersion: '*' },
|
|
865
|
+
* // 'react-dom': { singleton: true, requiredVersion: '*' },
|
|
866
|
+
* // lodash: { singleton: true, requiredVersion: '*' }
|
|
867
|
+
* // }
|
|
868
|
+
*/
|
|
869
|
+
declare function createQuickShared(packages: string[], options?: {
|
|
870
|
+
singleton?: boolean;
|
|
871
|
+
strictVersion?: boolean;
|
|
872
|
+
eager?: boolean;
|
|
873
|
+
requiredVersion?: string;
|
|
874
|
+
}): SharedObject;
|
|
875
|
+
|
|
876
|
+
/**
|
|
877
|
+
* 辅助函数:创建共享依赖配置(从多个来源)
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
* const shared = createSharedFromPackage(['react', 'react-dom'], {
|
|
881
|
+
* peerDependencies: true, // 从 peerDependencies 读取
|
|
882
|
+
* dependencies: false // 不从 dependencies 读取
|
|
883
|
+
* })
|
|
884
|
+
*/
|
|
885
|
+
declare function createSharedFromPackage(packages: string[], options?: {
|
|
886
|
+
peerDependencies?: boolean;
|
|
887
|
+
dependencies?: boolean;
|
|
888
|
+
defaultConfig?: SharedConfig;
|
|
889
|
+
}): SharedObject;
|
|
890
|
+
|
|
891
|
+
interface RspackRunnerOptions {
|
|
892
|
+
config: Configuration;
|
|
893
|
+
params: WebifyParams;
|
|
894
|
+
hooks?: WebifyHooks;
|
|
895
|
+
}
|
|
896
|
+
/**
|
|
897
|
+
* Rspack 执行器
|
|
898
|
+
* 使用 @rspack/core 和 @rspack/dev-server 进行构建和开发服务
|
|
899
|
+
*/
|
|
900
|
+
declare class RspackRunner {
|
|
901
|
+
private config;
|
|
902
|
+
private params;
|
|
903
|
+
private hooks?;
|
|
904
|
+
private server;
|
|
905
|
+
constructor(options: RspackRunnerOptions);
|
|
906
|
+
run(): Promise<void>;
|
|
907
|
+
/**
|
|
908
|
+
* 运行开发服务器(使用 @rspack/dev-server)
|
|
909
|
+
*/
|
|
910
|
+
private runDevServer;
|
|
911
|
+
/**
|
|
912
|
+
* 运行生产构建(使用 @rspack/core)
|
|
913
|
+
*/
|
|
914
|
+
private runBuild;
|
|
915
|
+
stop(): Promise<void>;
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* 运行 Rspack 构建
|
|
919
|
+
*/
|
|
920
|
+
declare const runRspackBuild: (params: WebifyParams, userConfig: Configuration, hooks?: WebifyHooks) => Promise<void>;
|
|
921
|
+
/** @deprecated 请使用 runRspackBuild */
|
|
922
|
+
declare const runWebpackBuild: (params: WebifyParams, userConfig: Configuration, hooks?: WebifyHooks) => Promise<void>;
|
|
923
|
+
|
|
924
|
+
/**
|
|
925
|
+
* CSS-in-TypeScript 插件配置
|
|
926
|
+
*
|
|
927
|
+
* 通过 @webify/css 包提供的 CSSInTSPlugin 实现
|
|
928
|
+
* 在 .style.ts 文件中用 TS 对象定义样式,编译时生成标准 CSS
|
|
929
|
+
*
|
|
930
|
+
* 设计理念:
|
|
931
|
+
* - .style.ts 编译后的 CSS 写入同目录的 .style.css 文件
|
|
932
|
+
* - .style.css 文件自然进入 Rspack 标准 CSS 管线
|
|
933
|
+
* - 复用已有的 css-loader → postcss-loader → CssExtractRspackPlugin 流程
|
|
934
|
+
* - 与 SCSS Modules 共享 PostCSS、压缩、打包等处理
|
|
935
|
+
* - 支持两种样式方案并存:SCSS Modules + CSS-in-TS
|
|
936
|
+
*
|
|
937
|
+
* @param cssInTS 配置项(true 启用默认配置,对象自定义配置)
|
|
938
|
+
* @param isService 是否为开发服务模式
|
|
939
|
+
* @returns RspackPluginInstance 或 undefined
|
|
940
|
+
*/
|
|
941
|
+
declare const setCSSInTSPlugin: (cssInTS: WebifyConfigOption["cssInTS"], isService: boolean) => any | undefined;
|
|
942
|
+
|
|
943
|
+
/**
|
|
944
|
+
* defineConfig 辅助函数(类型提示)
|
|
945
|
+
*/
|
|
946
|
+
declare const defineConfig: (config: WebifyConfigOption) => WebifyConfigOption;
|
|
947
|
+
|
|
948
|
+
export { type AdapterConfig, type AssetsType, type BuildOptions, type CdnConfig, type DevOption, type HtmlOptions, type ModuleFederationOption, type ModuleFederationSimplifiedOptions, type WebifyConfigOption as RsifyConfig, type RspackConfiguration, RspackRunner, type ScriptsConfig, type SharedDependenciesConfig, type StyleOptions, type WebifyConfigOption as WebifyConfig, type WebifyCommandLineConfigure as WebifyParams, type WebpackConfiguration, createExposes, createQuickShared, createReactShared, createRemotes, createRemotesFromEnv, rspackConfigPlugin as createRspackConfig, createShared, createSharedFromPackage, createVueShared, rspackConfigPlugin as createWebpackConfig, defineConfig, mergeShared, rspackConfigPlugin, runRspackBuild, runWebpackBuild, setCSSInTSPlugin, rspackConfigPlugin as webpackConfigPlugin, webpckConfigPlugin };
|