@empjs/cli 3.12.5-beta.3 → 4.0.0-alpha.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/README.md +2 -2
- package/dist/346.js +10 -0
- package/dist/627.js +5 -0
- package/dist/build.js +1 -0
- package/dist/dev.js +2 -0
- package/dist/dev.js.LICENSE.txt +1 -0
- package/dist/helper/buildPrint.d.ts +41 -0
- package/dist/helper/chalk.d.ts +3 -0
- package/dist/helper/color.d.ts +31 -0
- package/dist/helper/compilerWatcher.d.ts +5 -0
- package/dist/helper/empRoot.d.ts +1 -0
- package/dist/helper/getPort.d.ts +6 -0
- package/dist/helper/hmr/client.d.ts +0 -0
- package/dist/helper/hmr/config.d.ts +0 -0
- package/dist/helper/hmr/index.d.ts +0 -0
- package/dist/helper/hmr/overlay.d.ts +0 -0
- package/dist/helper/hmr/process-update.d.ts +0 -0
- package/dist/helper/hono.d.ts +0 -0
- package/dist/helper/index.d.ts +6 -0
- package/dist/helper/ipAddress.d.ts +27 -0
- package/dist/helper/loadConfig.d.ts +5 -0
- package/dist/helper/logger.d.ts +27 -0
- package/dist/helper/nodePolyfill.d.ts +1 -0
- package/dist/helper/openBrowser.d.ts +2 -0
- package/dist/helper/utils.d.ts +15 -0
- package/dist/index.d.ts +16 -841
- package/dist/index.js +1 -22
- package/dist/script/base.d.ts +6 -0
- package/dist/script/build.d.ts +15 -0
- package/dist/script/dev.d.ts +30 -0
- package/dist/script/index.d.ts +1 -0
- package/dist/script/serve.d.ts +7 -0
- package/dist/serve.js +1 -0
- package/dist/server/connect/dev.d.ts +9 -0
- package/dist/server/connect/prod.d.ts +3 -0
- package/dist/server/express/dev.d.ts +0 -0
- package/dist/server/express/prod.d.ts +0 -0
- package/dist/server/hono/dev.d.ts +0 -0
- package/dist/server/hono/devServer/devMiddleware.d.ts +0 -0
- package/dist/server/hono/prod.d.ts +0 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/types.d.ts +3 -0
- package/dist/server.js +1 -0
- package/dist/store/chain.d.ts +41 -0
- package/dist/store/empConfig.d.ts +75 -0
- package/dist/store/index.d.ts +179 -0
- package/dist/store/lifeCycle.d.ts +57 -0
- package/dist/store/rspack/builtInPlugin.d.ts +16 -0
- package/dist/store/rspack/common.d.ts +21 -0
- package/dist/store/rspack/css.d.ts +10 -0
- package/dist/store/rspack/entries.d.ts +44 -0
- package/dist/store/rspack/index.d.ts +7 -0
- package/dist/store/rspack/module.d.ts +22 -0
- package/dist/store/rspack/plugin.d.ts +19 -0
- package/dist/store/server.d.ts +39 -0
- package/dist/types/config.d.ts +413 -0
- package/dist/types/env.d.ts +3 -0
- package/dist/types/plugin.d.ts +6 -0
- package/package.json +14 -19
- package/dist/index.cjs +0 -22
- package/dist/index.d.cts +0 -841
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
export type LifeCycleOptions = Partial<LifeCycle>;
|
|
2
|
+
export declare class LifeCycle {
|
|
3
|
+
op: LifeCycleOptions;
|
|
4
|
+
constructor(op?: LifeCycleOptions);
|
|
5
|
+
/**
|
|
6
|
+
* 获取 empOptions 之后、初始化 empConfig 之前
|
|
7
|
+
*/
|
|
8
|
+
afterGetEmpOptions(): Promise<void>;
|
|
9
|
+
/**
|
|
10
|
+
* RspackPlugin 插件执行之前
|
|
11
|
+
*/
|
|
12
|
+
beforePlugin(): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* RspackPlugin 插件执行之后
|
|
15
|
+
*/
|
|
16
|
+
afterPlugin(): Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* RspackModule 插件执行之后
|
|
19
|
+
*/
|
|
20
|
+
beforeModule(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* RspackModule 插件执行之后
|
|
23
|
+
*/
|
|
24
|
+
afterModule(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* empPlugin 插件执行之前
|
|
27
|
+
*/
|
|
28
|
+
beforeEmpPlugin(): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* empPlugin 插件执行之后
|
|
31
|
+
*/
|
|
32
|
+
afterEmpPlugin(): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* 产物构建完成前
|
|
35
|
+
*/
|
|
36
|
+
beforeBuild(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* 产物构建完成后
|
|
39
|
+
*/
|
|
40
|
+
afterBulid(): Promise<void>;
|
|
41
|
+
/**
|
|
42
|
+
* devServer启动前
|
|
43
|
+
*/
|
|
44
|
+
beforeDevServe(): Promise<void>;
|
|
45
|
+
/**
|
|
46
|
+
* devServer启动后
|
|
47
|
+
*/
|
|
48
|
+
afterDevServe(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* server启动前
|
|
51
|
+
*/
|
|
52
|
+
beforeServe(): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* server启动后
|
|
55
|
+
*/
|
|
56
|
+
afterServe(): Promise<void>;
|
|
57
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Compiler } from '@rspack/core';
|
|
2
|
+
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
3
|
+
import type { InjectTagsType } from '../../types/config';
|
|
4
|
+
export { HtmlWebpackPlugin };
|
|
5
|
+
export declare function getPolyfillEntry(): string;
|
|
6
|
+
export declare class EmpPolyfillPlugin {
|
|
7
|
+
constructor();
|
|
8
|
+
apply(compiler: Compiler): void;
|
|
9
|
+
}
|
|
10
|
+
export declare class HtmlEmpInjectPlugin {
|
|
11
|
+
PluginName: string;
|
|
12
|
+
chunk: string;
|
|
13
|
+
files: InjectTagsType;
|
|
14
|
+
constructor(files: InjectTagsType, name?: string, chunk?: string);
|
|
15
|
+
apply(compiler: any): void;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CacheOptions } from '@rspack/core';
|
|
2
|
+
import type { GlobalStore } from '..';
|
|
3
|
+
declare class RspackCommon {
|
|
4
|
+
store: GlobalStore;
|
|
5
|
+
setup(store: GlobalStore): Promise<void>;
|
|
6
|
+
/**
|
|
7
|
+
* 适配缓存多样性设置
|
|
8
|
+
*/
|
|
9
|
+
get cache(): CacheOptions;
|
|
10
|
+
/**
|
|
11
|
+
* 解决单项目多开的缓存问题
|
|
12
|
+
*/
|
|
13
|
+
get name(): string;
|
|
14
|
+
common(): Promise<void>;
|
|
15
|
+
checkTsconfig(): Promise<void>;
|
|
16
|
+
stats(): Promise<void>;
|
|
17
|
+
devServer(): Promise<void>;
|
|
18
|
+
optimization(): Promise<void>;
|
|
19
|
+
}
|
|
20
|
+
declare const _default: RspackCommon;
|
|
21
|
+
export default _default;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { GlobalStore } from '..';
|
|
2
|
+
export declare class RspackCss {
|
|
3
|
+
store: GlobalStore;
|
|
4
|
+
setup(store: GlobalStore): Promise<void>;
|
|
5
|
+
sass(): Promise<void>;
|
|
6
|
+
less(): Promise<void>;
|
|
7
|
+
css(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
declare const _default: RspackCss;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RspackOptions } from '@rspack/core';
|
|
2
|
+
import type { GlobalStore } from '..';
|
|
3
|
+
import type { EmpConfig } from '../empConfig';
|
|
4
|
+
type EntriesConfigType = {
|
|
5
|
+
[chunk: string]: {
|
|
6
|
+
html: EmpConfig['html'];
|
|
7
|
+
entry: RspackOptions['entry'];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
declare class RspackEntries {
|
|
11
|
+
store: GlobalStore;
|
|
12
|
+
entriesConfig: EntriesConfigType;
|
|
13
|
+
setup(store: GlobalStore): Promise<void>;
|
|
14
|
+
private setHtmlConfig;
|
|
15
|
+
private prepareAndSetAsset;
|
|
16
|
+
/**
|
|
17
|
+
* injectPolyfill 插入 polyfill 代码
|
|
18
|
+
*/
|
|
19
|
+
private injectPolyfill;
|
|
20
|
+
/**
|
|
21
|
+
* chunk name 格式化 去除 后缀
|
|
22
|
+
* @param filename
|
|
23
|
+
* @returns
|
|
24
|
+
*/
|
|
25
|
+
private setChunk;
|
|
26
|
+
private setTemplate;
|
|
27
|
+
private setFavicion;
|
|
28
|
+
/**
|
|
29
|
+
*
|
|
30
|
+
* @param filename 文件名
|
|
31
|
+
* @param op html plugin 配置
|
|
32
|
+
* @param absPath 文件 绝对路径
|
|
33
|
+
*/
|
|
34
|
+
private setEntryItem;
|
|
35
|
+
setRspackHtmlPlugin(config: EmpConfig['html'], chunk: string): void;
|
|
36
|
+
setRspackEntry(entry: RspackOptions['entry']): void;
|
|
37
|
+
init(): Promise<void>;
|
|
38
|
+
setAutoPage(): Promise<void>;
|
|
39
|
+
setDefaultEntry(): Promise<void>;
|
|
40
|
+
setEntryByConfig(): void;
|
|
41
|
+
toConfig(): void;
|
|
42
|
+
}
|
|
43
|
+
declare const _default: RspackEntries;
|
|
44
|
+
export default _default;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { GlobalStore } from '..';
|
|
2
|
+
declare class RspackModule {
|
|
3
|
+
store: GlobalStore;
|
|
4
|
+
private swcJsOptions;
|
|
5
|
+
private swcTsOptions;
|
|
6
|
+
private coreJs;
|
|
7
|
+
setup(store: GlobalStore): Promise<void>;
|
|
8
|
+
run(): Promise<void>;
|
|
9
|
+
private rspackGenerator;
|
|
10
|
+
private rspackParser;
|
|
11
|
+
private get isPolyfill();
|
|
12
|
+
private swcParser;
|
|
13
|
+
private swcJsc;
|
|
14
|
+
private get swcCoreVersion();
|
|
15
|
+
private swcOptions;
|
|
16
|
+
swcInitOptions(): void;
|
|
17
|
+
jsDataUrl(): void;
|
|
18
|
+
scripts(): Promise<void>;
|
|
19
|
+
files(): Promise<void>;
|
|
20
|
+
}
|
|
21
|
+
declare const _default: RspackModule;
|
|
22
|
+
export default _default;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { GlobalStore } from '..';
|
|
2
|
+
declare class RspackPlugin {
|
|
3
|
+
store: GlobalStore;
|
|
4
|
+
setup(store: GlobalStore): Promise<void>;
|
|
5
|
+
beforeLifeCycle(): void;
|
|
6
|
+
anylayze(): Promise<void>;
|
|
7
|
+
tsCheckerRspackPlugin(): false | undefined;
|
|
8
|
+
define(): Promise<void>;
|
|
9
|
+
copy(): Promise<void>;
|
|
10
|
+
progress(): Promise<void>;
|
|
11
|
+
minify(): void;
|
|
12
|
+
redoctor(): void;
|
|
13
|
+
sourceMapDevToolPlugin(): void;
|
|
14
|
+
circularDependency(): void;
|
|
15
|
+
cssChunkingPlugin(): void;
|
|
16
|
+
esmLibraryPlugin(): void;
|
|
17
|
+
}
|
|
18
|
+
declare const _default: RspackPlugin;
|
|
19
|
+
export default _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { GlobalStore } from './';
|
|
2
|
+
export declare class StoreServer {
|
|
3
|
+
ip: string;
|
|
4
|
+
host: string;
|
|
5
|
+
isAutoDevBase: boolean;
|
|
6
|
+
isHttps: boolean;
|
|
7
|
+
httpsType: 'default' | 'h2' | 'h3';
|
|
8
|
+
protocol: string;
|
|
9
|
+
port: number;
|
|
10
|
+
store: GlobalStore;
|
|
11
|
+
publicPath: any;
|
|
12
|
+
publicHasHttp: boolean;
|
|
13
|
+
isOpenBrower: boolean;
|
|
14
|
+
url: string;
|
|
15
|
+
urls: {
|
|
16
|
+
localUrlForBrowser: string;
|
|
17
|
+
localUrlForTerminal: string;
|
|
18
|
+
lanUrlForTerminal: string;
|
|
19
|
+
lanUrlForConfig: string;
|
|
20
|
+
};
|
|
21
|
+
constructor(store: GlobalStore);
|
|
22
|
+
/**
|
|
23
|
+
* 获取config后重新适配 server 配置信息
|
|
24
|
+
*/
|
|
25
|
+
setupOnEmpOptionSync(): Promise<void>;
|
|
26
|
+
/**
|
|
27
|
+
* 获取 server 所有配置信息
|
|
28
|
+
*/
|
|
29
|
+
get config(): {};
|
|
30
|
+
/**
|
|
31
|
+
* setupOnEmpOptionSync 之后,store setup 之后
|
|
32
|
+
*/
|
|
33
|
+
setupOnStore(): Promise<void>;
|
|
34
|
+
startOpen(): void;
|
|
35
|
+
getcert(): Promise<any>;
|
|
36
|
+
private setHttps;
|
|
37
|
+
private setAutoDevBase;
|
|
38
|
+
private get isHttpBase();
|
|
39
|
+
}
|
|
@@ -0,0 +1,413 @@
|
|
|
1
|
+
import type { InspectOptions } from 'node:util';
|
|
2
|
+
import type { RsdoctorRspackPlugin } from '@rsdoctor/rspack-plugin';
|
|
3
|
+
import type { DevServer as devServerConfig, CacheOptions, Externals, HtmlRspackPluginOptions, Output, Resolve, Configuration as RsConfig, RuleSetRule, SourceMapDevToolPluginOptions, SwcJsMinimizerRspackPluginOptions } from '@rspack/core';
|
|
4
|
+
import type { HtmlTagObject } from 'html-webpack-plugin';
|
|
5
|
+
import type { Options as SassOptions } from 'sass-embedded';
|
|
6
|
+
import { Chain } from '../store/chain';
|
|
7
|
+
import type { LifeCycleOptions } from '../store/lifeCycle';
|
|
8
|
+
import type { TsCheckerRspackPluginOptions } from 'ts-checker-rspack-plugin/lib/plugin-options';
|
|
9
|
+
import type { EMP3PluginType } from './plugin';
|
|
10
|
+
export type LoggerType = 'debug' | 'info' | 'warn' | 'error';
|
|
11
|
+
export type RsdoctorRspackPluginOptions = ConstructorParameters<typeof RsdoctorRspackPlugin>[0];
|
|
12
|
+
export type CssminOptionsType = any;
|
|
13
|
+
export type DebugType = {
|
|
14
|
+
loggerLevel?: LoggerType;
|
|
15
|
+
clearLog?: boolean;
|
|
16
|
+
progress?: boolean;
|
|
17
|
+
showRsconfig?: boolean | string | InspectOptions;
|
|
18
|
+
/**
|
|
19
|
+
* 已经弃用
|
|
20
|
+
*/
|
|
21
|
+
showPerformance?: boolean;
|
|
22
|
+
showScriptDebug?: boolean;
|
|
23
|
+
rsdoctor?: boolean | RsdoctorRspackPluginOptions;
|
|
24
|
+
newTreeshaking?: boolean;
|
|
25
|
+
devShowAllLog?: boolean;
|
|
26
|
+
warnRuleAsWarning?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 是否显示执行日志
|
|
29
|
+
* @default false
|
|
30
|
+
*/
|
|
31
|
+
infrastructureLogging?: RsConfig['infrastructureLogging'];
|
|
32
|
+
/**
|
|
33
|
+
* 开启并行 code spitting
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
/**
|
|
37
|
+
* https://rspack.rs/zh/plugins/rspack/css-chunking-plugin
|
|
38
|
+
* 启用 CssChunkingPlugin 后,SplitChunksPlugin 将不再处理 CSS 模块。 这意味着 optimization.splitChunks 等配置对 CSS 模块将不再生效,所有 CSS 模块的代码分割逻辑完全由 CssChunkingPlugin 处理。
|
|
39
|
+
*/
|
|
40
|
+
cssChunkingPlugin?: boolean;
|
|
41
|
+
};
|
|
42
|
+
export type ServerType = devServerConfig & {
|
|
43
|
+
/**
|
|
44
|
+
* 访问 host
|
|
45
|
+
* @default '0.0.0.0'
|
|
46
|
+
*/
|
|
47
|
+
host?: string;
|
|
48
|
+
/**
|
|
49
|
+
* 访问 端口
|
|
50
|
+
* @default 8000
|
|
51
|
+
*/
|
|
52
|
+
port?: number;
|
|
53
|
+
/**
|
|
54
|
+
* 自动打开
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
open?: devServerConfig['open'];
|
|
58
|
+
/**
|
|
59
|
+
* 热重载
|
|
60
|
+
* @default true
|
|
61
|
+
*/
|
|
62
|
+
hot?: devServerConfig['hot'];
|
|
63
|
+
http2?: boolean;
|
|
64
|
+
https?: boolean;
|
|
65
|
+
};
|
|
66
|
+
export type PolyfillType = {
|
|
67
|
+
/**
|
|
68
|
+
* 注入兼容代码
|
|
69
|
+
* module federation 入口 建议使用 entry
|
|
70
|
+
* @default false
|
|
71
|
+
*/
|
|
72
|
+
mode?: 'entry' | 'usage';
|
|
73
|
+
/**
|
|
74
|
+
* 当 mode=entry时,注入cdn替代 entry chunk
|
|
75
|
+
*/
|
|
76
|
+
entryCdn?: string;
|
|
77
|
+
splitChunks?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* 手动注入兼容代码,避免usage出现分析纰漏问题
|
|
80
|
+
* @default ['es.object.values', 'es.object.entries', 'es.array.flat']
|
|
81
|
+
*/
|
|
82
|
+
include?: string[];
|
|
83
|
+
/**
|
|
84
|
+
* 选择core-js的兼容版本有助于切换适当的代码体积
|
|
85
|
+
* @default stable
|
|
86
|
+
*/
|
|
87
|
+
coreJsFeatures?: 'full' | 'actual' | 'stable' | 'es';
|
|
88
|
+
/**
|
|
89
|
+
* @swc/helpers 外置
|
|
90
|
+
* @default false
|
|
91
|
+
*/
|
|
92
|
+
externalHelpers?: boolean;
|
|
93
|
+
/**
|
|
94
|
+
* 浏览器 兼容版本
|
|
95
|
+
*/
|
|
96
|
+
browserslist?: string[];
|
|
97
|
+
};
|
|
98
|
+
export type SourceMapType = {
|
|
99
|
+
js: RsConfig['devtool'] | false;
|
|
100
|
+
css: boolean;
|
|
101
|
+
devToolPluginOptions?: SourceMapDevToolPluginOptions;
|
|
102
|
+
};
|
|
103
|
+
export type BuildType = {
|
|
104
|
+
/**
|
|
105
|
+
* 生成代码目录
|
|
106
|
+
* @default 'dist'
|
|
107
|
+
*/
|
|
108
|
+
outDir?: string;
|
|
109
|
+
/**
|
|
110
|
+
* 生成静态目录
|
|
111
|
+
* @default 'assets'
|
|
112
|
+
*/
|
|
113
|
+
assetsDir?: string;
|
|
114
|
+
/**
|
|
115
|
+
* 生成包含 js,css,asset 合集目录
|
|
116
|
+
* @default ''
|
|
117
|
+
*/
|
|
118
|
+
staticDir?: string;
|
|
119
|
+
/**
|
|
120
|
+
* 静态文件路径
|
|
121
|
+
* @default 'public'
|
|
122
|
+
*/
|
|
123
|
+
publicDir?: string;
|
|
124
|
+
/**
|
|
125
|
+
* named 使用有意义、方便调试的内容当作模块 id。此选项会在开发环境下默认开启。
|
|
126
|
+
* deterministic 使用对模块标识符哈希后的数字当作模块 id,有益于长期缓存。此选项会在生产环境下默认开启。
|
|
127
|
+
*/
|
|
128
|
+
moduleIds?: 'named' | 'deterministic';
|
|
129
|
+
/**
|
|
130
|
+
* chunkIds
|
|
131
|
+
* @default named|deterministic
|
|
132
|
+
*/
|
|
133
|
+
chunkIds?: false | 'natural' | 'named' | 'deterministic' | 'size' | 'total-size';
|
|
134
|
+
/**
|
|
135
|
+
* 是否生成 source map
|
|
136
|
+
* @default true
|
|
137
|
+
*/
|
|
138
|
+
sourcemap?: boolean | SourceMapType;
|
|
139
|
+
/**
|
|
140
|
+
* sourcemap 类型
|
|
141
|
+
* 默认 source-map
|
|
142
|
+
* @deprecated 请使用 build.sourcemap.js 设置
|
|
143
|
+
*/
|
|
144
|
+
devtool?: RsConfig['devtool'];
|
|
145
|
+
/**
|
|
146
|
+
* 是否压缩
|
|
147
|
+
* @default true
|
|
148
|
+
*/
|
|
149
|
+
minify?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* 设置内置压缩器配置
|
|
152
|
+
* @default {}
|
|
153
|
+
*/
|
|
154
|
+
minOptions?: SwcJsMinimizerRspackPluginOptions;
|
|
155
|
+
cssminOptions?: CssminOptionsType;
|
|
156
|
+
/**
|
|
157
|
+
* 生成代码 参考 https://swc.rs/docs/configuring-swc#jsctarget
|
|
158
|
+
*/
|
|
159
|
+
target?: JscTarget;
|
|
160
|
+
/**
|
|
161
|
+
* 是否用 ESM
|
|
162
|
+
*/
|
|
163
|
+
useESM?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* 注入兼容代码
|
|
166
|
+
* module federation 入口 建议使用 entry
|
|
167
|
+
* @default false
|
|
168
|
+
*/
|
|
169
|
+
polyfill?: PolyfillType;
|
|
170
|
+
/**
|
|
171
|
+
* swc 配置
|
|
172
|
+
*/
|
|
173
|
+
swcConfig?: {
|
|
174
|
+
transform?: {
|
|
175
|
+
useDefineForClassFields?: boolean;
|
|
176
|
+
};
|
|
177
|
+
preserveAllComments?: boolean;
|
|
178
|
+
};
|
|
179
|
+
};
|
|
180
|
+
export type JscTarget = 'es3' | 'es5' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022';
|
|
181
|
+
export interface HtmlType extends HtmlRspackPluginOptions {
|
|
182
|
+
/**
|
|
183
|
+
* 基于项目的根目录 index.html url
|
|
184
|
+
* @default src/index.html
|
|
185
|
+
*/
|
|
186
|
+
template?: string;
|
|
187
|
+
/**
|
|
188
|
+
* 基于项目的根目录 favicon url
|
|
189
|
+
* @default src/favicon.ico
|
|
190
|
+
*/
|
|
191
|
+
favicon?: string;
|
|
192
|
+
/**
|
|
193
|
+
* 自定义挂载节点的 id,默认为 'emp-root'
|
|
194
|
+
* @default 'emp-root'
|
|
195
|
+
*/
|
|
196
|
+
mountId?: string;
|
|
197
|
+
/**
|
|
198
|
+
* 网站语言
|
|
199
|
+
*/
|
|
200
|
+
lang?: string;
|
|
201
|
+
/**
|
|
202
|
+
* externals 文件插入到html
|
|
203
|
+
*/
|
|
204
|
+
tags?: InjectTagsTypeItem[];
|
|
205
|
+
templateParameters?: any;
|
|
206
|
+
cache?: boolean;
|
|
207
|
+
}
|
|
208
|
+
export type EntriesType = {
|
|
209
|
+
[entryFilename: string]: HtmlType;
|
|
210
|
+
};
|
|
211
|
+
export interface ModuleTransform {
|
|
212
|
+
exclude?: RuleSetRule['exclude'][];
|
|
213
|
+
include?: RuleSetRule['include'][];
|
|
214
|
+
/**
|
|
215
|
+
* 默认exclude /(node_modules|bower_components)/
|
|
216
|
+
* @default false
|
|
217
|
+
*/
|
|
218
|
+
defaultExclude?: boolean;
|
|
219
|
+
}
|
|
220
|
+
export type CssSassOptionsType = {
|
|
221
|
+
api?: 'modern' | 'modern-compiler';
|
|
222
|
+
sassOptions?: SassOptions<'async'>;
|
|
223
|
+
mode?: 'default' | 'modern' | 'legacy';
|
|
224
|
+
implementation?: object | string;
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Less 配置项
|
|
228
|
+
*
|
|
229
|
+
* 将 less-loader 的常用选项暴露到 empConfig.css.less,并提供 TS 提示。
|
|
230
|
+
*/
|
|
231
|
+
export type CssLessOptionsType = {
|
|
232
|
+
/**
|
|
233
|
+
* 传递给 less-loader 的 lessOptions。
|
|
234
|
+
*
|
|
235
|
+
* - `javascriptEnabled`: 允许在 Less 中使用 JS 表达式与函数。
|
|
236
|
+
* 许多第三方 UI 库(如 Ant Design)在主题构建或函数型变量计算中需要开启。
|
|
237
|
+
* 若关闭,可能导致变量计算/函数调用失败(构建报错或样式异常)。
|
|
238
|
+
* 默认值:`true`。
|
|
239
|
+
*
|
|
240
|
+
* - `math`: 控制数学表达式解析策略(Less v4)。
|
|
241
|
+
* - `'always'`: 始终解析数学表达式(兼容旧 Less 裸除法写法,升级更平滑)。
|
|
242
|
+
* - `'parens-division'`: 仅在括号内解析除法,更安全的中间策略。
|
|
243
|
+
* - `'strict'`: 更严格的解析方式,需显式括号。
|
|
244
|
+
* 默认值:`'always'`,用于提升对旧代码及部分生态的兼容性。
|
|
245
|
+
*/
|
|
246
|
+
lessOptions?: {
|
|
247
|
+
javascriptEnabled?: boolean;
|
|
248
|
+
math?: 'always' | 'parens-division' | 'strict';
|
|
249
|
+
};
|
|
250
|
+
};
|
|
251
|
+
export type ExternalsItemType = {
|
|
252
|
+
/**
|
|
253
|
+
* 模块名
|
|
254
|
+
* @example react-dom
|
|
255
|
+
*/
|
|
256
|
+
module?: string;
|
|
257
|
+
/**
|
|
258
|
+
* 全局变量
|
|
259
|
+
* @example ReactDom
|
|
260
|
+
*/
|
|
261
|
+
global?: string;
|
|
262
|
+
/**
|
|
263
|
+
* 入口地址
|
|
264
|
+
* 不填则可以通过 emp-config 里的 html.files.js[url] 传入合并后的请求
|
|
265
|
+
* 如 http://...?react&react-dom&react-router&mobx
|
|
266
|
+
* @example http://
|
|
267
|
+
*/
|
|
268
|
+
entry?: string;
|
|
269
|
+
/**
|
|
270
|
+
* 类型入口
|
|
271
|
+
* @default js
|
|
272
|
+
* @enum js | css
|
|
273
|
+
* @example css
|
|
274
|
+
*/
|
|
275
|
+
type?: string;
|
|
276
|
+
};
|
|
277
|
+
export type RsTarget = RsConfig['target'];
|
|
278
|
+
export type AutoPagesType = {
|
|
279
|
+
/**
|
|
280
|
+
* 基于src寻找入口目录
|
|
281
|
+
* @default pages
|
|
282
|
+
*/
|
|
283
|
+
path?: string;
|
|
284
|
+
};
|
|
285
|
+
export type EmpOptions = {
|
|
286
|
+
/**
|
|
287
|
+
* publicPath 根路径 可参考webpack,业务模式默认为 auto
|
|
288
|
+
* html 部分 publicPath 默认为 undefined,可设置全量域名或子目录适配,也可以单独在html设置 Public
|
|
289
|
+
*
|
|
290
|
+
* @default undefined
|
|
291
|
+
*/
|
|
292
|
+
base?: string;
|
|
293
|
+
/**
|
|
294
|
+
* 构建target
|
|
295
|
+
*/
|
|
296
|
+
target?: RsConfig['target'];
|
|
297
|
+
/**
|
|
298
|
+
* 启动后 自动设置 base 为当前 Ip+port的路径如 base = http://127.0.0.1:8080/ 并且固定 ws 方便代理调试
|
|
299
|
+
*/
|
|
300
|
+
autoDevBase?: boolean;
|
|
301
|
+
/**
|
|
302
|
+
* 启动后 进入自动搜寻入口的方式
|
|
303
|
+
* 可以通过 html 或 entries 设置 模版配置
|
|
304
|
+
*/
|
|
305
|
+
autoPages?: boolean | AutoPagesType;
|
|
306
|
+
/**
|
|
307
|
+
* 项目代码路径
|
|
308
|
+
* @default 'src'
|
|
309
|
+
*/
|
|
310
|
+
appSrc?: string;
|
|
311
|
+
/**
|
|
312
|
+
* 项目代码入口文件 如 `src/index.js`
|
|
313
|
+
* (*)entries 设置后 该选项失效
|
|
314
|
+
* @default 'index.js'
|
|
315
|
+
*/
|
|
316
|
+
appEntry?: string;
|
|
317
|
+
build?: BuildType;
|
|
318
|
+
plugins?: EMP3PluginType[];
|
|
319
|
+
html?: HtmlType;
|
|
320
|
+
entries?: EntriesType;
|
|
321
|
+
server?: ServerType;
|
|
322
|
+
debug?: DebugType;
|
|
323
|
+
chain?: (chain: Chain) => void;
|
|
324
|
+
/**
|
|
325
|
+
* css 相关设置
|
|
326
|
+
* @argument sass default {mode: 'modern'}
|
|
327
|
+
*/
|
|
328
|
+
css?: {
|
|
329
|
+
sass?: CssSassOptionsType & {
|
|
330
|
+
webpackImporter?: boolean;
|
|
331
|
+
warnRuleAsWarning?: boolean;
|
|
332
|
+
additionalData?: string;
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Less 配置
|
|
336
|
+
*
|
|
337
|
+
* 默认:`{ lessOptions: { javascriptEnabled: true, math: 'always' } }`
|
|
338
|
+
* 如项目严格遵循 Less v4 新语法且不依赖 JS 表达式,可考虑:
|
|
339
|
+
* - 将 `math` 调整为 `'parens-division'` 或 `'strict'`;
|
|
340
|
+
* - 将 `javascriptEnabled` 设为 `false`。
|
|
341
|
+
*/
|
|
342
|
+
less?: CssLessOptionsType;
|
|
343
|
+
prifixName?: string;
|
|
344
|
+
};
|
|
345
|
+
/**
|
|
346
|
+
* 模块编译
|
|
347
|
+
* 如 node_modules 模块 是否加入编译
|
|
348
|
+
*/
|
|
349
|
+
moduleTransform?: ModuleTransform;
|
|
350
|
+
/**
|
|
351
|
+
* 缓存目录
|
|
352
|
+
* @default 'node_modules/.emp-cache'
|
|
353
|
+
*/
|
|
354
|
+
cacheDir?: string;
|
|
355
|
+
/**
|
|
356
|
+
* 启用缓存
|
|
357
|
+
* @default persistent 为 内存缓存 false 关闭 persistent 持久缓存
|
|
358
|
+
*/
|
|
359
|
+
cache?: boolean | 'persistent' | CacheOptions;
|
|
360
|
+
/**
|
|
361
|
+
* 全局环境替换
|
|
362
|
+
*/
|
|
363
|
+
define?: Record<string, any>;
|
|
364
|
+
/**
|
|
365
|
+
* 是否创建 cjs 的 process.env 或者 esm 的 import.meta.env
|
|
366
|
+
* all 两者创建
|
|
367
|
+
* esm 创建 import.meta.env
|
|
368
|
+
* cjs 创建 process.env
|
|
369
|
+
* none 不创建
|
|
370
|
+
* @default cjs
|
|
371
|
+
*/
|
|
372
|
+
defineFix?: 'all' | 'esm' | 'cjs' | 'none';
|
|
373
|
+
/**
|
|
374
|
+
* externals
|
|
375
|
+
*/
|
|
376
|
+
externals?: Externals;
|
|
377
|
+
/**
|
|
378
|
+
* resolve
|
|
379
|
+
*/
|
|
380
|
+
resolve?: Resolve;
|
|
381
|
+
/**
|
|
382
|
+
* output
|
|
383
|
+
*/
|
|
384
|
+
output?: Output;
|
|
385
|
+
/**
|
|
386
|
+
* emp 执行周期
|
|
387
|
+
*/
|
|
388
|
+
lifeCycle?: LifeCycleOptions;
|
|
389
|
+
/**
|
|
390
|
+
* ignoreWarnings
|
|
391
|
+
* @default [/Conflicting order/, /Failed to parse source map/]
|
|
392
|
+
*/
|
|
393
|
+
ignoreWarnings?: RsConfig['ignoreWarnings'];
|
|
394
|
+
/**
|
|
395
|
+
* 详情 https://github.com/rspack-contrib/ts-checker-rspack-plugin
|
|
396
|
+
*/
|
|
397
|
+
tsCheckerRspackPlugin?: TsCheckerRspackPluginOptions | boolean;
|
|
398
|
+
/**
|
|
399
|
+
* 是否显示日志标题
|
|
400
|
+
* @default undefined
|
|
401
|
+
*/
|
|
402
|
+
showLogTitle?: (o?: any) => void;
|
|
403
|
+
};
|
|
404
|
+
export type Override<What, With> = Omit<What, keyof With> & With;
|
|
405
|
+
export type InjectTagsType = InjectTagsTypeItem[];
|
|
406
|
+
export type InjectTagsTypeItem = {
|
|
407
|
+
pos?: 'head' | 'body';
|
|
408
|
+
} & Partial<HtmlTagObject>;
|
|
409
|
+
export type StoreRootPaths = {
|
|
410
|
+
tsConfig?: string;
|
|
411
|
+
empConfig?: string;
|
|
412
|
+
pkg?: string;
|
|
413
|
+
};
|