@doracli/webpack 0.0.2 → 0.0.4
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 +1 -2
- package/lib/cjs/index.js +815 -106
- package/lib/esm/index.js +801 -108
- package/lib/type/index.d.ts +137 -26
- package/package.json +16 -16
package/lib/type/index.d.ts
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
|
+
import * as http from 'http';
|
|
1
2
|
import * as webpack from 'webpack';
|
|
2
3
|
import webpack__default, { Configuration, Stats, Compiler as Compiler$1 } from 'webpack';
|
|
3
|
-
import * as http from 'http';
|
|
4
4
|
import WebpackDevServer, { Configuration as Configuration$1 } from 'webpack-dev-server';
|
|
5
5
|
import { TPlainObject, TAny } from '@cclr/lang';
|
|
6
|
-
import { CompilerBase, ConfigCtx } from '@doracli/helper';
|
|
6
|
+
import { CompilerBase, ConfigCtx, HtmlAssetManager } from '@doracli/helper';
|
|
7
7
|
import * as _doracli_type from '@doracli/type';
|
|
8
8
|
import { TModule as TModule$1 } from '@doracli/type';
|
|
9
9
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
err?: Error | null;
|
|
13
|
-
stats?: Stats;
|
|
14
|
-
}>;
|
|
10
|
+
import { TOnionFun } from '@cclr/utils';
|
|
11
|
+
import { TDoraConfigMultiple } from '@doracli/type/src/dora-config-multiple';
|
|
15
12
|
|
|
16
13
|
type TAction = 'build' | 'server' | 'lib';
|
|
17
14
|
type TEnvParams = {
|
|
@@ -19,6 +16,10 @@ type TEnvParams = {
|
|
|
19
16
|
workRootDir: string;
|
|
20
17
|
format?: TModule$1;
|
|
21
18
|
};
|
|
19
|
+
type TModuleInfo = {
|
|
20
|
+
name: string;
|
|
21
|
+
input: string;
|
|
22
|
+
};
|
|
22
23
|
|
|
23
24
|
type TMode = Configuration['mode'];
|
|
24
25
|
type TEntry = Configuration['entry'];
|
|
@@ -33,8 +34,8 @@ type TPlugins = Configuration['plugins'];
|
|
|
33
34
|
type TOptimization = Configuration['optimization'];
|
|
34
35
|
|
|
35
36
|
type TBuildResult = {
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
err: Error;
|
|
38
|
+
stats: Stats;
|
|
38
39
|
};
|
|
39
40
|
declare class Compiler extends CompilerBase<Configuration, {
|
|
40
41
|
build: Promise<TBuildResult>;
|
|
@@ -42,16 +43,18 @@ declare class Compiler extends CompilerBase<Configuration, {
|
|
|
42
43
|
server: Promise<WebpackDevServer>;
|
|
43
44
|
}> {
|
|
44
45
|
context: (webpackConfig: Configuration) => Promise<{
|
|
46
|
+
compiler: webpack__default.Compiler;
|
|
45
47
|
rebuild: () => Promise<TBuildResult>;
|
|
46
48
|
cancel: () => Promise<void>;
|
|
49
|
+
server: (serverOptions: Configuration$1, webpackConfig?: Configuration) => Promise<WebpackDevServer<any, http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>>;
|
|
47
50
|
}>;
|
|
48
51
|
inOutMap: (inputOutputMap: Record<string, string>) => Promise<TBuildResult>;
|
|
49
52
|
input: (input: string) => Promise<{
|
|
50
53
|
output: (output: TOutput) => Promise<TBuildResult>;
|
|
51
54
|
}>;
|
|
52
55
|
build: (webpackConfig: Configuration) => Promise<TBuildResult>;
|
|
53
|
-
watch: (watchOptions: Configuration["watchOptions"], webpackConfig: Configuration, cb?: (err: Error | null, stats?: Stats) => void) =>
|
|
54
|
-
server: (serverOptions: Configuration$1, webpackConfig?: Configuration) => Promise<WebpackDevServer<any, http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>>;
|
|
56
|
+
watch: (watchOptions: Configuration["watchOptions"], webpackConfig: Configuration, cb?: (err: Error | null, stats?: Stats) => void) => webpack__default.Watching;
|
|
57
|
+
server: (serverOptions: Configuration$1, webpackConfig?: Configuration, userCompiler?: webpack__default.Compiler) => Promise<WebpackDevServer<any, http.Server<typeof http.IncomingMessage, typeof http.ServerResponse>>>;
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
declare const getDevServer: (serviceConfig: Configuration$1) => Configuration$1;
|
|
@@ -98,11 +101,11 @@ declare class TsconfigPlugin {
|
|
|
98
101
|
|
|
99
102
|
declare const getTsconfigPlugin: (envParams: TEnvParams) => TsconfigPlugin;
|
|
100
103
|
|
|
101
|
-
|
|
102
|
-
minimize?: boolean;
|
|
104
|
+
interface IReactPluginsPresetOptions {
|
|
103
105
|
WebpackBundleAnalyzerOptions?: TAny;
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
+
cssFilename?: string;
|
|
107
|
+
}
|
|
108
|
+
declare const getReactPluginsPreset: (envParams: TEnvParams, options: IReactPluginsPresetOptions) => TPlugins;
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* 获取webpack的resolve配置
|
|
@@ -113,8 +116,9 @@ declare const getResolve: (resolveConfig: TResolve) => TResolve;
|
|
|
113
116
|
|
|
114
117
|
declare const getResolveLoader: () => TResolveLoader;
|
|
115
118
|
|
|
116
|
-
|
|
117
|
-
|
|
119
|
+
/**
|
|
120
|
+
* 单任务上下文
|
|
121
|
+
*/
|
|
118
122
|
declare class Ctx {
|
|
119
123
|
configCtx: ConfigCtx;
|
|
120
124
|
webpackConfig: Configuration;
|
|
@@ -126,8 +130,122 @@ declare class Ctx {
|
|
|
126
130
|
updateDevServerConfig(config: Configuration$1): void;
|
|
127
131
|
getDoraConfig(): _doracli_type.TDoraConfig;
|
|
128
132
|
geTDoraConfigWebpack(): _doracli_type.TDoraConfigWebpack;
|
|
133
|
+
getDoraConfigServiceConfig(): Partial<_doracli_type.TDoraConfigService>;
|
|
129
134
|
}
|
|
130
135
|
|
|
136
|
+
/**
|
|
137
|
+
* webpack dev server 配置 中间件
|
|
138
|
+
* @returns
|
|
139
|
+
*/
|
|
140
|
+
declare const webpackDevServerMw: () => TOnionFun<Ctx>;
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* webpack dev server 配置 中间件
|
|
144
|
+
* @returns
|
|
145
|
+
*/
|
|
146
|
+
declare const webpackDevtoolMw: () => TOnionFun<Ctx>;
|
|
147
|
+
|
|
148
|
+
declare const envParamsMw: (envParams: TEnvParams) => TOnionFun<Ctx>;
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* webpack dev server 配置 中间件
|
|
152
|
+
* @returns
|
|
153
|
+
*/
|
|
154
|
+
declare const webpackExternalsMw: () => TOnionFun<Ctx>;
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* webpack dev server 配置 中间件
|
|
158
|
+
* @returns
|
|
159
|
+
*/
|
|
160
|
+
declare const webpackEntryWholeMw: () => TOnionFun<Ctx>;
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 处理 multiple
|
|
164
|
+
* - 1. multiple 变成多入口,多出口 的 entry格式
|
|
165
|
+
* - 2. 上下文一定要拆分过
|
|
166
|
+
*/
|
|
167
|
+
declare const multipleToInOutMw: () => TOnionFun<Ctx>;
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* webpack dev server 配置 中间件
|
|
171
|
+
* @returns
|
|
172
|
+
*/
|
|
173
|
+
declare const webpackOutputMw: () => TOnionFun<Ctx>;
|
|
174
|
+
|
|
175
|
+
type TLogLevel = 'none' | 'verbose' | 'error' | 'warn' | 'info' | 'log';
|
|
176
|
+
/**
|
|
177
|
+
* webpack dev server 配置 中间件
|
|
178
|
+
* @returns
|
|
179
|
+
*/
|
|
180
|
+
declare const webpackLogLevelMw: (logLevel?: TLogLevel) => TOnionFun<Ctx>;
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* webpack dev server 配置 中间件
|
|
184
|
+
* @returns
|
|
185
|
+
*/
|
|
186
|
+
declare const webpackReactModuleMw: () => TOnionFun<Ctx>;
|
|
187
|
+
|
|
188
|
+
/**
|
|
189
|
+
* webpack dev server 配置 中间件
|
|
190
|
+
* @returns
|
|
191
|
+
*/
|
|
192
|
+
declare const webpackPlainMw: () => TOnionFun<Ctx>;
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* 替换 React 相关的插件配置
|
|
196
|
+
* @returns
|
|
197
|
+
*/
|
|
198
|
+
declare const webpackReactPluginMw: (options?: IReactPluginsPresetOptions) => TOnionFun<Ctx>;
|
|
199
|
+
/**
|
|
200
|
+
* 替换 React 相关的插件配置
|
|
201
|
+
* @returns
|
|
202
|
+
*/
|
|
203
|
+
declare const webpackMultipleReactPluginMw: () => TOnionFun<Ctx>;
|
|
204
|
+
/**
|
|
205
|
+
* 添加 HtmlWebpackPlugin 插件配置
|
|
206
|
+
* @returns
|
|
207
|
+
*/
|
|
208
|
+
declare const webpackHtmlPluginMw: () => TOnionFun<Ctx>;
|
|
209
|
+
|
|
210
|
+
/**
|
|
211
|
+
* webpack dev server 配置 中间件
|
|
212
|
+
* @returns
|
|
213
|
+
*/
|
|
214
|
+
declare const webpackResolveMw: () => TOnionFun<Ctx>;
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* webpack dev server 配置 中间件
|
|
218
|
+
* @returns
|
|
219
|
+
*/
|
|
220
|
+
declare const webpackResolveLoaderMw: () => TOnionFun<Ctx>;
|
|
221
|
+
|
|
222
|
+
type TBundleAsset = {
|
|
223
|
+
name: string;
|
|
224
|
+
scripts: string[];
|
|
225
|
+
styles: string[];
|
|
226
|
+
runtimeChunks: string[];
|
|
227
|
+
};
|
|
228
|
+
declare function collectAssetUrls(compiler: webpack__default.Compiler, onChange?: (params: Record<string, TBundleAsset>) => void, options?: {
|
|
229
|
+
hostname?: string;
|
|
230
|
+
port?: number | string;
|
|
231
|
+
}): () => Record<string, TBundleAsset>;
|
|
232
|
+
|
|
233
|
+
declare const htmlRouteGeneratorMw: (htmlAssetManager: HtmlAssetManager, configCtx: ConfigCtx) => Promise<(req: any, res: any, next: any) => Promise<void>>;
|
|
234
|
+
|
|
235
|
+
/**
|
|
236
|
+
* 把配置拆分成多个标准的配置上下文,使用于webpack
|
|
237
|
+
* - 主要是拆分成不同的入口输出分组
|
|
238
|
+
* @param configCtx
|
|
239
|
+
*/
|
|
240
|
+
declare const splitDoraConfig: (configCtx: ConfigCtx) => ConfigCtx[];
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* 根据配置分组
|
|
244
|
+
* @param multiple
|
|
245
|
+
* @returns
|
|
246
|
+
*/
|
|
247
|
+
declare const splitDoraConfigMultiple: (multiple: TDoraConfigMultiple[]) => TDoraConfigMultiple[][];
|
|
248
|
+
|
|
131
249
|
declare const mergeWebpackConfig: <T extends Partial<Configuration>>(first: T | undefined, second: T | undefined) => Partial<Configuration>;
|
|
132
250
|
/**
|
|
133
251
|
* 合并多个 devServer 配置
|
|
@@ -136,12 +254,5 @@ declare const mergeWebpackConfig: <T extends Partial<Configuration>>(first: T |
|
|
|
136
254
|
*/
|
|
137
255
|
declare const mergeServerConfig: <T extends Partial<Configuration$1>>(...configs: (T | undefined)[]) => Configuration$1;
|
|
138
256
|
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
* @param options
|
|
142
|
-
* @param compiler
|
|
143
|
-
*/
|
|
144
|
-
declare const service: (options: Configuration$1, compiler: Compiler$1) => Promise<void>;
|
|
145
|
-
|
|
146
|
-
export { Compiler, Ctx, babelLoader, build, createCompiler, cssLoader, getBabelConfig, getCssBaseLoader, getDevServer, getDevtool, getEntry, getExternals, getHtmlWebpackPlugin, getMode, getOptimization, getOutput, getReactModulePreset, getReactPluginsPreset, getResolve, getResolveLoader, getTsconfigPlugin, lessLoader, mergeServerConfig, mergeWebpackConfig, postcssLoader, postcssPresetEnv, sassLoader, service, styleLoader };
|
|
147
|
-
export type { TAction, TBuildResult, TDevtool, TEntry, TEnvParams, TExperiments, TExternals, TMode, TModule, TOptimization, TOutput, TPlugins, TResolve, TResolveLoader };
|
|
257
|
+
export { Compiler, Ctx, babelLoader, collectAssetUrls, cssLoader, envParamsMw, getBabelConfig, getCssBaseLoader, getDevServer, getDevtool, getEntry, getExternals, getHtmlWebpackPlugin, getMode, getOptimization, getOutput, getReactModulePreset, getReactPluginsPreset, getResolve, getResolveLoader, getTsconfigPlugin, htmlRouteGeneratorMw, lessLoader, mergeServerConfig, mergeWebpackConfig, multipleToInOutMw, postcssLoader, postcssPresetEnv, sassLoader, splitDoraConfig, splitDoraConfigMultiple, styleLoader, webpackDevServerMw, webpackDevtoolMw, webpackEntryWholeMw, webpackExternalsMw, webpackHtmlPluginMw, webpackLogLevelMw, webpackMultipleReactPluginMw, webpackOutputMw, webpackPlainMw, webpackReactModuleMw, webpackReactPluginMw, webpackResolveLoaderMw, webpackResolveMw };
|
|
258
|
+
export type { IReactPluginsPresetOptions, TAction, TBuildResult, TBundleAsset, TDevtool, TEntry, TEnvParams, TExperiments, TExternals, TLogLevel, TMode, TModule, TModuleInfo, TOptimization, TOutput, TPlugins, TResolve, TResolveLoader };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doracli/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "use webpack",
|
|
5
5
|
"author": "cclr <18843152354@163.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -28,36 +28,36 @@
|
|
|
28
28
|
"build": "ccf build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@dorabag/open-browser": "^1.0.
|
|
31
|
+
"@dorabag/open-browser": "^1.0.16"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cclr/lang": "^0.1.
|
|
35
|
-
"@cclr/utils": "^0.1.
|
|
36
|
-
"@dorabag/config-loader": "^1.0.
|
|
34
|
+
"@cclr/lang": "^0.1.44",
|
|
35
|
+
"@cclr/utils": "^0.1.44",
|
|
36
|
+
"@dorabag/config-loader": "^1.0.16",
|
|
37
37
|
"@dorabag/file-pro": "^1.0.10",
|
|
38
38
|
"@dorabag/open-browser": "^1.0.7",
|
|
39
|
-
"@dorabag/srv-tool": "^1.0.
|
|
40
|
-
"@doracli/helper": "^0.0.
|
|
41
|
-
"@doracli/preset-babel": "^0.0.
|
|
42
|
-
"@doracli/type": "^0.0.
|
|
39
|
+
"@dorabag/srv-tool": "^1.0.16",
|
|
40
|
+
"@doracli/helper": "^0.0.4",
|
|
41
|
+
"@doracli/preset-babel": "^0.0.4",
|
|
42
|
+
"@doracli/type": "^0.0.4",
|
|
43
43
|
"babel-loader": "^10.0.0",
|
|
44
44
|
"css-loader": "^7.1.2",
|
|
45
|
-
"html-webpack-plugin": "^5.6.
|
|
46
|
-
"less": "^4.
|
|
45
|
+
"html-webpack-plugin": "^5.6.5",
|
|
46
|
+
"less": "^4.5.1",
|
|
47
47
|
"less-loader": "^12.3.0",
|
|
48
48
|
"mini-css-extract-plugin": "^2.9.4",
|
|
49
49
|
"picocolors": "^1.1.1",
|
|
50
50
|
"postcss": "^8.5.6",
|
|
51
51
|
"postcss-loader": "^8.2.0",
|
|
52
|
-
"postcss-preset-env": "^10.
|
|
53
|
-
"sass": "^1.
|
|
52
|
+
"postcss-preset-env": "^10.5.0",
|
|
53
|
+
"sass": "^1.97.0",
|
|
54
54
|
"sass-loader": "^16.0.6",
|
|
55
55
|
"style-loader": "^4.0.0",
|
|
56
|
-
"terser-webpack-plugin": "^5.3.
|
|
57
|
-
"webpack": "^5.
|
|
56
|
+
"terser-webpack-plugin": "^5.3.16",
|
|
57
|
+
"webpack": "^5.104.0",
|
|
58
58
|
"webpack-bundle-analyzer": "^4.10.2",
|
|
59
59
|
"webpack-dev-server": "^5.2.2",
|
|
60
60
|
"webpackbar": "^7.0.0"
|
|
61
61
|
},
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "a978bb7e7b32c192b1eb527dae5f25bbe1a2af86"
|
|
63
63
|
}
|