@doracli/webpack-react 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/lib/cjs/index.js +770 -358
- package/lib/esm/index.js +764 -361
- package/lib/type/index.d.ts +20 -9
- package/package.json +10 -9
package/lib/cjs/index.js
CHANGED
|
@@ -1,109 +1,50 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var lang = require('@cclr/lang');
|
|
4
|
+
var filePro = require('@dorabag/file-pro');
|
|
3
5
|
var helper = require('@doracli/helper');
|
|
4
6
|
var webpack = require('@doracli/webpack');
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
var updateDevtool = function updateDevtool(ctx) {
|
|
9
|
-
var devtool = webpack.getDevtool(ctx.envParams);
|
|
10
|
-
ctx.updateWebpackConfig({
|
|
11
|
-
devtool: devtool
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
// export const getExternals = (ctx: Ctx): TExternals => {
|
|
16
|
-
// const { externals } = ctx.geTDoraConfigWebpack();
|
|
17
|
-
// if (externals) return externals;
|
|
18
|
-
|
|
19
|
-
// return [];
|
|
20
|
-
// };
|
|
21
|
-
|
|
22
|
-
var updateExternals = function updateExternals(ctx) {
|
|
23
|
-
var _ctx$getDoraConfig = ctx.getDoraConfig(),
|
|
24
|
-
userExternals = _ctx$getDoraConfig.externals;
|
|
25
|
-
var externals = webpack.getExternals(userExternals);
|
|
26
|
-
ctx.updateWebpackConfig({
|
|
27
|
-
externals: externals
|
|
28
|
-
});
|
|
29
|
-
};
|
|
7
|
+
var utils = require('@cclr/utils');
|
|
8
|
+
var srvTool = require('@dorabag/srv-tool');
|
|
30
9
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
var
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
ctx.updateWebpackConfig({
|
|
49
|
-
module: module
|
|
50
|
-
});
|
|
51
|
-
return $return();
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
var updateOptimization = function updateOptimization(ctx) {
|
|
56
|
-
var _ctx$getDoraConfig = ctx.getDoraConfig(),
|
|
57
|
-
minimize = _ctx$getDoraConfig.minimize;
|
|
58
|
-
var optimization = webpack.getOptimization({
|
|
59
|
-
minimize: minimize
|
|
60
|
-
});
|
|
61
|
-
ctx.updateWebpackConfig({
|
|
62
|
-
optimization: optimization
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
var updateOutput = function updateOutput(ctx) {
|
|
67
|
-
var output = webpack.getOutput(ctx.envParams);
|
|
68
|
-
ctx.updateWebpackConfig({
|
|
69
|
-
output: output
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
var ActionMap = {
|
|
74
|
-
build: helper.EnvEnum.prod,
|
|
75
|
-
server: helper.EnvEnum.dev,
|
|
76
|
-
lib: helper.EnvEnum.prod
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
var updatePlugins = function updatePlugins(ctx) {
|
|
80
|
-
return new Promise(function ($return, $error) {
|
|
81
|
-
var cdnConfig, _ctx$getDoraConfig, minimize, plugins;
|
|
82
|
-
return Promise.resolve(helper.parseCdnConfig(ctx.configCtx.getCdnConfig(), ActionMap[ctx.envParams.action])).then(function ($await_1) {
|
|
83
|
-
try {
|
|
84
|
-
cdnConfig = $await_1;
|
|
85
|
-
_ctx$getDoraConfig = ctx.getDoraConfig(), minimize = _ctx$getDoraConfig.minimize;
|
|
86
|
-
plugins = webpack.getReactPluginsPreset(ctx.envParams, {
|
|
87
|
-
HtmlWebpackPluginOptions: cdnConfig,
|
|
88
|
-
minimize: minimize
|
|
89
|
-
});
|
|
90
|
-
return $return(ctx.updateWebpackConfig({
|
|
91
|
-
plugins: plugins
|
|
92
|
-
}));
|
|
93
|
-
} catch ($boundEx) {
|
|
94
|
-
return $error($boundEx);
|
|
10
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) {
|
|
11
|
+
try {
|
|
12
|
+
var i = n[a](c),
|
|
13
|
+
u = i.value;
|
|
14
|
+
} catch (n) {
|
|
15
|
+
return void e(n);
|
|
16
|
+
}
|
|
17
|
+
i.done ? t(u) : Promise.resolve(u).then(r, o);
|
|
18
|
+
}
|
|
19
|
+
function _asyncToGenerator(n) {
|
|
20
|
+
return function () {
|
|
21
|
+
var t = this,
|
|
22
|
+
e = arguments;
|
|
23
|
+
return new Promise(function (r, o) {
|
|
24
|
+
var a = n.apply(t, e);
|
|
25
|
+
function _next(n) {
|
|
26
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
|
|
95
27
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
|
|
103
|
-
return n;
|
|
28
|
+
function _throw(n) {
|
|
29
|
+
asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
|
|
30
|
+
}
|
|
31
|
+
_next(void 0);
|
|
32
|
+
});
|
|
33
|
+
};
|
|
104
34
|
}
|
|
105
|
-
function
|
|
106
|
-
if (
|
|
35
|
+
function _classCallCheck(a, n) {
|
|
36
|
+
if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
|
|
37
|
+
}
|
|
38
|
+
function _defineProperties(e, r) {
|
|
39
|
+
for (var t = 0; t < r.length; t++) {
|
|
40
|
+
var o = r[t];
|
|
41
|
+
o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
function _createClass(e, r, t) {
|
|
45
|
+
return r && _defineProperties(e.prototype, r), Object.defineProperty(e, "prototype", {
|
|
46
|
+
writable: false
|
|
47
|
+
}), e;
|
|
107
48
|
}
|
|
108
49
|
function _defineProperty(e, r, t) {
|
|
109
50
|
return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
@@ -113,12 +54,6 @@ function _defineProperty(e, r, t) {
|
|
|
113
54
|
writable: true
|
|
114
55
|
}) : e[r] = t, e;
|
|
115
56
|
}
|
|
116
|
-
function _iterableToArray(r) {
|
|
117
|
-
if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
|
|
118
|
-
}
|
|
119
|
-
function _nonIterableSpread() {
|
|
120
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
121
|
-
}
|
|
122
57
|
function ownKeys(e, r) {
|
|
123
58
|
var t = Object.keys(e);
|
|
124
59
|
if (Object.getOwnPropertySymbols) {
|
|
@@ -140,8 +75,113 @@ function _objectSpread2(e) {
|
|
|
140
75
|
}
|
|
141
76
|
return e;
|
|
142
77
|
}
|
|
143
|
-
function
|
|
144
|
-
|
|
78
|
+
function _regenerator() {
|
|
79
|
+
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
|
|
80
|
+
var e,
|
|
81
|
+
t,
|
|
82
|
+
r = "function" == typeof Symbol ? Symbol : {},
|
|
83
|
+
n = r.iterator || "@@iterator",
|
|
84
|
+
o = r.toStringTag || "@@toStringTag";
|
|
85
|
+
function i(r, n, o, i) {
|
|
86
|
+
var c = n && n.prototype instanceof Generator ? n : Generator,
|
|
87
|
+
u = Object.create(c.prototype);
|
|
88
|
+
return _regeneratorDefine(u, "_invoke", function (r, n, o) {
|
|
89
|
+
var i,
|
|
90
|
+
c,
|
|
91
|
+
u,
|
|
92
|
+
f = 0,
|
|
93
|
+
p = o || [],
|
|
94
|
+
y = false,
|
|
95
|
+
G = {
|
|
96
|
+
p: 0,
|
|
97
|
+
n: 0,
|
|
98
|
+
v: e,
|
|
99
|
+
a: d,
|
|
100
|
+
f: d.bind(e, 4),
|
|
101
|
+
d: function (t, r) {
|
|
102
|
+
return i = t, c = 0, u = e, G.n = r, a;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
function d(r, n) {
|
|
106
|
+
for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
|
|
107
|
+
var o,
|
|
108
|
+
i = p[t],
|
|
109
|
+
d = G.p,
|
|
110
|
+
l = i[2];
|
|
111
|
+
r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
|
|
112
|
+
}
|
|
113
|
+
if (o || r > 1) return a;
|
|
114
|
+
throw y = true, n;
|
|
115
|
+
}
|
|
116
|
+
return function (o, p, l) {
|
|
117
|
+
if (f > 1) throw TypeError("Generator is already running");
|
|
118
|
+
for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
|
|
119
|
+
i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
|
|
120
|
+
try {
|
|
121
|
+
if (f = 2, i) {
|
|
122
|
+
if (c || (o = "next"), t = i[o]) {
|
|
123
|
+
if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
|
|
124
|
+
if (!t.done) return t;
|
|
125
|
+
u = t.value, c < 2 && (c = 0);
|
|
126
|
+
} else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
|
|
127
|
+
i = e;
|
|
128
|
+
} else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
|
|
129
|
+
} catch (t) {
|
|
130
|
+
i = e, c = 1, u = t;
|
|
131
|
+
} finally {
|
|
132
|
+
f = 1;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
value: t,
|
|
137
|
+
done: y
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
}(r, o, i), true), u;
|
|
141
|
+
}
|
|
142
|
+
var a = {};
|
|
143
|
+
function Generator() {}
|
|
144
|
+
function GeneratorFunction() {}
|
|
145
|
+
function GeneratorFunctionPrototype() {}
|
|
146
|
+
t = Object.getPrototypeOf;
|
|
147
|
+
var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
|
|
148
|
+
return this;
|
|
149
|
+
}), t),
|
|
150
|
+
u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
|
|
151
|
+
function f(e) {
|
|
152
|
+
return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
|
|
153
|
+
}
|
|
154
|
+
return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
|
|
155
|
+
return this;
|
|
156
|
+
}), _regeneratorDefine(u, "toString", function () {
|
|
157
|
+
return "[object Generator]";
|
|
158
|
+
}), (_regenerator = function () {
|
|
159
|
+
return {
|
|
160
|
+
w: i,
|
|
161
|
+
m: f
|
|
162
|
+
};
|
|
163
|
+
})();
|
|
164
|
+
}
|
|
165
|
+
function _regeneratorDefine(e, r, n, t) {
|
|
166
|
+
var i = Object.defineProperty;
|
|
167
|
+
try {
|
|
168
|
+
i({}, "", {});
|
|
169
|
+
} catch (e) {
|
|
170
|
+
i = 0;
|
|
171
|
+
}
|
|
172
|
+
_regeneratorDefine = function (e, r, n, t) {
|
|
173
|
+
function o(r, n) {
|
|
174
|
+
_regeneratorDefine(e, r, function (e) {
|
|
175
|
+
return this._invoke(r, n, e);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
r ? i ? i(e, r, {
|
|
179
|
+
value: n,
|
|
180
|
+
enumerable: !t,
|
|
181
|
+
configurable: !t,
|
|
182
|
+
writable: !t
|
|
183
|
+
}) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
|
|
184
|
+
}, _regeneratorDefine(e, r, n, t);
|
|
145
185
|
}
|
|
146
186
|
function _toPrimitive(t, r) {
|
|
147
187
|
if ("object" != typeof t || !t) return t;
|
|
@@ -157,164 +197,370 @@ function _toPropertyKey(t) {
|
|
|
157
197
|
var i = _toPrimitive(t, "string");
|
|
158
198
|
return "symbol" == typeof i ? i : i + "";
|
|
159
199
|
}
|
|
160
|
-
function _unsupportedIterableToArray(r, a) {
|
|
161
|
-
if (r) {
|
|
162
|
-
if ("string" == typeof r) return _arrayLikeToArray(r, a);
|
|
163
|
-
var t = {}.toString.call(r).slice(8, -1);
|
|
164
|
-
return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
|
|
165
|
-
}
|
|
166
|
-
}
|
|
167
200
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
201
|
+
var getBuildCtx = function getBuildCtx(configCtx, envParams) {
|
|
202
|
+
var workflow = helper.configCtxWorkflow(new webpack.Ctx(configCtx));
|
|
203
|
+
workflow.use(webpack.envParamsMw(envParams));
|
|
204
|
+
workflow.use(webpack.webpackPlainMw());
|
|
205
|
+
workflow.use(webpack.webpackEntryWholeMw());
|
|
206
|
+
workflow.use(webpack.webpackOutputMw());
|
|
207
|
+
workflow.use(webpack.webpackDevtoolMw());
|
|
208
|
+
workflow.use(webpack.webpackExternalsMw());
|
|
209
|
+
workflow.use(webpack.webpackResolveLoaderMw());
|
|
210
|
+
workflow.use(webpack.webpackResolveMw());
|
|
211
|
+
workflow.use(webpack.webpackReactModuleMw());
|
|
212
|
+
workflow.use(webpack.webpackReactPluginMw());
|
|
213
|
+
workflow.use(webpack.webpackHtmlPluginMw());
|
|
214
|
+
return workflow.getResult();
|
|
215
|
+
};
|
|
216
|
+
var buildBase = /*#__PURE__*/function () {
|
|
217
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ctx) {
|
|
218
|
+
var compiler, timeEnd, res;
|
|
219
|
+
return _regenerator().w(function (_context) {
|
|
220
|
+
while (1) switch (_context.n) {
|
|
221
|
+
case 0:
|
|
222
|
+
compiler = new webpack.Compiler(ctx.webpackConfig);
|
|
223
|
+
timeEnd = helper.cLog.time('build');
|
|
224
|
+
_context.n = 1;
|
|
225
|
+
return compiler.build({});
|
|
226
|
+
case 1:
|
|
227
|
+
res = _context.v;
|
|
228
|
+
timeEnd();
|
|
229
|
+
return _context.a(2, res);
|
|
230
|
+
}
|
|
231
|
+
}, _callee);
|
|
232
|
+
}));
|
|
233
|
+
return function buildBase(_x) {
|
|
234
|
+
return _ref.apply(this, arguments);
|
|
186
235
|
};
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
236
|
+
}();
|
|
237
|
+
var builderBaseWorkfolw = function builderBaseWorkfolw(workflow) {
|
|
238
|
+
workflow.use(webpack.webpackPlainMw());
|
|
239
|
+
workflow.use(webpack.webpackDevtoolMw());
|
|
240
|
+
workflow.use(webpack.webpackExternalsMw());
|
|
241
|
+
workflow.use(webpack.webpackResolveLoaderMw());
|
|
242
|
+
workflow.use(webpack.webpackResolveMw());
|
|
243
|
+
workflow.use(webpack.webpackReactModuleMw());
|
|
244
|
+
workflow.use(webpack.webpackMultipleReactPluginMw());
|
|
245
|
+
workflow.use(webpack.webpackLogLevelMw('warn'));
|
|
190
246
|
};
|
|
247
|
+
var buildMultipleBase = /*#__PURE__*/function () {
|
|
248
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(ctx) {
|
|
249
|
+
var context, generateConfigHtml, assetAllMap;
|
|
250
|
+
return _regenerator().w(function (_context3) {
|
|
251
|
+
while (1) switch (_context3.n) {
|
|
252
|
+
case 0:
|
|
253
|
+
_context3.n = 1;
|
|
254
|
+
return new webpack.Compiler(ctx.webpackConfig).context({});
|
|
255
|
+
case 1:
|
|
256
|
+
context = _context3.v;
|
|
257
|
+
generateConfigHtml = new helper.GenerateConfigHtml(ctx.configCtx);
|
|
258
|
+
_context3.n = 2;
|
|
259
|
+
return generateConfigHtml.init();
|
|
260
|
+
case 2:
|
|
261
|
+
generateConfigHtml.addConfigCdn();
|
|
262
|
+
assetAllMap = {};
|
|
263
|
+
webpack.collectAssetUrls(context.compiler, function (assetMap) {
|
|
264
|
+
lang.obj.extend(assetAllMap, assetMap);
|
|
265
|
+
});
|
|
266
|
+
_context3.n = 3;
|
|
267
|
+
return context.rebuild();
|
|
268
|
+
case 3:
|
|
269
|
+
_context3.n = 4;
|
|
270
|
+
return lang.obj.forEachAsync(assetAllMap, /*#__PURE__*/function () {
|
|
271
|
+
var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(asset) {
|
|
272
|
+
var _ctx$webpackConfig$ou;
|
|
273
|
+
var name, scripts, styles;
|
|
274
|
+
return _regenerator().w(function (_context2) {
|
|
275
|
+
while (1) switch (_context2.n) {
|
|
276
|
+
case 0:
|
|
277
|
+
name = asset.name, scripts = asset.scripts, styles = asset.styles;
|
|
278
|
+
_context2.n = 1;
|
|
279
|
+
return generateConfigHtml.copy().addBodyScripts(scripts.map(function (script) {
|
|
280
|
+
return "/".concat(name, "/").concat(filePro.getFilename(script), ".js");
|
|
281
|
+
})).addHeadStyles(styles.map(function (script) {
|
|
282
|
+
return "/".concat(name, "/").concat(filePro.getFilename(script), ".css");
|
|
283
|
+
})).writeToFile("".concat((_ctx$webpackConfig$ou = ctx.webpackConfig.output) === null || _ctx$webpackConfig$ou === void 0 ? void 0 : _ctx$webpackConfig$ou.path, "/").concat(name, "/index.html"));
|
|
284
|
+
case 1:
|
|
285
|
+
return _context2.a(2);
|
|
286
|
+
}
|
|
287
|
+
}, _callee2);
|
|
288
|
+
}));
|
|
289
|
+
return function (_x3) {
|
|
290
|
+
return _ref3.apply(this, arguments);
|
|
291
|
+
};
|
|
292
|
+
}());
|
|
293
|
+
case 4:
|
|
294
|
+
return _context3.a(2);
|
|
295
|
+
}
|
|
296
|
+
}, _callee3);
|
|
297
|
+
}));
|
|
298
|
+
return function buildMultipleBase(_x2) {
|
|
299
|
+
return _ref2.apply(this, arguments);
|
|
300
|
+
};
|
|
301
|
+
}();
|
|
191
302
|
|
|
192
|
-
var
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
303
|
+
var ActionMap = {
|
|
304
|
+
build: helper.EnvEnum.prod,
|
|
305
|
+
server: helper.EnvEnum.dev,
|
|
306
|
+
lib: helper.EnvEnum.prod,
|
|
307
|
+
dev: helper.EnvEnum.dev
|
|
197
308
|
};
|
|
198
309
|
|
|
199
|
-
var
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
310
|
+
var getConfigCtx = /*#__PURE__*/function () {
|
|
311
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(envParams, cmd, defaultDora) {
|
|
312
|
+
var workflow;
|
|
313
|
+
return _regenerator().w(function (_context) {
|
|
314
|
+
while (1) switch (_context.n) {
|
|
315
|
+
case 0:
|
|
316
|
+
workflow = helper.configCtxWorkflow(new helper.ConfigCtx());
|
|
317
|
+
workflow.use(helper.collectBaseConfigMw(envParams.workRootDir, cmd));
|
|
318
|
+
workflow.use(helper.collectPackageJsonMw());
|
|
319
|
+
workflow.use(helper.collectTsconfigJsonMw());
|
|
320
|
+
workflow.use(helper.collectDoraConfigMw(ActionMap[envParams.action]));
|
|
321
|
+
workflow.use(helper.collectCdnConfigMw(ActionMap[envParams.action]));
|
|
322
|
+
workflow.use(helper.wholeDoraConfigMw(defaultDora));
|
|
323
|
+
workflow.use(helper.wholeDoraInoutMw());
|
|
324
|
+
workflow.use(helper.clearMw());
|
|
325
|
+
_context.n = 1;
|
|
326
|
+
return workflow.getResult();
|
|
327
|
+
case 1:
|
|
328
|
+
return _context.a(2, _context.v);
|
|
329
|
+
}
|
|
330
|
+
}, _callee);
|
|
331
|
+
}));
|
|
332
|
+
return function getConfigCtx(_x, _x2, _x3) {
|
|
333
|
+
return _ref.apply(this, arguments);
|
|
334
|
+
};
|
|
335
|
+
}();
|
|
336
|
+
|
|
337
|
+
var ModuleHtmlMultiple = /*#__PURE__*/function () {
|
|
338
|
+
function ModuleHtmlMultiple() {
|
|
339
|
+
var publicPath = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '/';
|
|
340
|
+
_classCallCheck(this, ModuleHtmlMultiple);
|
|
341
|
+
this.publicPath = publicPath;
|
|
342
|
+
_defineProperty(this, "assetMap", {});
|
|
343
|
+
_defineProperty(this, "dynamicHtml", new helper.DynamicHtml());
|
|
344
|
+
_defineProperty(this, "initAwaitList", []);
|
|
345
|
+
}
|
|
346
|
+
return _createClass(ModuleHtmlMultiple, [{
|
|
347
|
+
key: "setAssetList",
|
|
348
|
+
value: function setAssetList(assetMap) {
|
|
349
|
+
this.assetMap = assetMap;
|
|
350
|
+
this.initAwaitList.forEach(function (cb) {
|
|
351
|
+
return cb();
|
|
352
|
+
});
|
|
353
|
+
this.initAwaitList = [];
|
|
354
|
+
}
|
|
355
|
+
}, {
|
|
356
|
+
key: "getAssetMap",
|
|
357
|
+
value: function getAssetMap() {
|
|
358
|
+
return this.assetMap;
|
|
359
|
+
}
|
|
360
|
+
}, {
|
|
361
|
+
key: "getModuleHtml",
|
|
362
|
+
value: function () {
|
|
363
|
+
var _getModuleHtml = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(moduleName) {
|
|
364
|
+
var _this = this;
|
|
365
|
+
var asset, moduleHtml;
|
|
366
|
+
return _regenerator().w(function (_context) {
|
|
367
|
+
while (1) switch (_context.n) {
|
|
368
|
+
case 0:
|
|
369
|
+
if (!(Object.keys(this.assetMap).length === 0)) {
|
|
370
|
+
_context.n = 1;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
_context.n = 1;
|
|
374
|
+
return new Promise(function (resolve) {
|
|
375
|
+
_this.initAwaitList.push(function () {
|
|
376
|
+
resolve();
|
|
377
|
+
});
|
|
378
|
+
});
|
|
379
|
+
case 1:
|
|
380
|
+
asset = this.assetMap[moduleName];
|
|
381
|
+
if (asset) {
|
|
382
|
+
_context.n = 2;
|
|
383
|
+
break;
|
|
252
384
|
}
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
385
|
+
throw new Error("Module ".concat(moduleName, " asset not found."));
|
|
386
|
+
case 2:
|
|
387
|
+
moduleHtml = this.dynamicHtml.copy();
|
|
388
|
+
moduleHtml.addBodyScripts(asset.scripts.map(function (src) {
|
|
389
|
+
return {
|
|
390
|
+
src: src,
|
|
391
|
+
order: 0
|
|
392
|
+
};
|
|
393
|
+
}));
|
|
394
|
+
moduleHtml.addHeadStyles(asset.styles.map(function (src) {
|
|
395
|
+
return {
|
|
396
|
+
src: src,
|
|
397
|
+
order: 0
|
|
398
|
+
};
|
|
399
|
+
}));
|
|
400
|
+
return _context.a(2, moduleHtml.generateHtmlTemplate());
|
|
256
401
|
}
|
|
257
|
-
},
|
|
258
|
-
}
|
|
259
|
-
|
|
402
|
+
}, _callee, this);
|
|
403
|
+
}));
|
|
404
|
+
function getModuleHtml(_x) {
|
|
405
|
+
return _getModuleHtml.apply(this, arguments);
|
|
260
406
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
};
|
|
407
|
+
return getModuleHtml;
|
|
408
|
+
}()
|
|
409
|
+
}]);
|
|
410
|
+
}();
|
|
264
411
|
|
|
265
|
-
var
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
412
|
+
var getServerCtx = function getServerCtx(configCtx, envParams) {
|
|
413
|
+
var workflow = helper.configCtxWorkflow(new webpack.Ctx(configCtx));
|
|
414
|
+
workflow.use(webpack.envParamsMw(envParams));
|
|
415
|
+
workflow.use(webpack.webpackPlainMw());
|
|
416
|
+
workflow.use(webpack.webpackEntryWholeMw());
|
|
417
|
+
workflow.use(webpack.webpackOutputMw());
|
|
418
|
+
workflow.use(webpack.webpackDevtoolMw());
|
|
419
|
+
workflow.use(webpack.webpackExternalsMw());
|
|
420
|
+
workflow.use(webpack.webpackResolveLoaderMw());
|
|
421
|
+
workflow.use(webpack.webpackResolveMw());
|
|
422
|
+
workflow.use(webpack.webpackReactModuleMw());
|
|
423
|
+
workflow.use(webpack.webpackReactPluginMw());
|
|
424
|
+
workflow.use(webpack.webpackHtmlPluginMw());
|
|
425
|
+
workflow.use(webpack.webpackDevServerMw());
|
|
426
|
+
workflow.use(webpack.webpackLogLevelMw('warn'));
|
|
427
|
+
return workflow.getResult();
|
|
428
|
+
};
|
|
429
|
+
var serverBase = /*#__PURE__*/function () {
|
|
430
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(ctx) {
|
|
431
|
+
var context;
|
|
432
|
+
return _regenerator().w(function (_context) {
|
|
433
|
+
while (1) switch (_context.n) {
|
|
434
|
+
case 0:
|
|
435
|
+
_context.n = 1;
|
|
436
|
+
return new webpack.Compiler(ctx.webpackConfig).context({});
|
|
437
|
+
case 1:
|
|
438
|
+
context = _context.v;
|
|
439
|
+
_context.n = 2;
|
|
440
|
+
return context.server(ctx.devServerConfig);
|
|
441
|
+
case 2:
|
|
442
|
+
return _context.a(2);
|
|
282
443
|
}
|
|
283
|
-
},
|
|
284
|
-
});
|
|
444
|
+
}, _callee);
|
|
445
|
+
}));
|
|
446
|
+
return function serverBase(_x) {
|
|
447
|
+
return _ref.apply(this, arguments);
|
|
448
|
+
};
|
|
449
|
+
}();
|
|
450
|
+
var serverMultipleBase = /*#__PURE__*/function () {
|
|
451
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(ctx) {
|
|
452
|
+
var context, _ctx$getDoraConfigSer, publicPath, dynamicHtml, moduleNames, origSetup;
|
|
453
|
+
return _regenerator().w(function (_context2) {
|
|
454
|
+
while (1) switch (_context2.n) {
|
|
455
|
+
case 0:
|
|
456
|
+
_context2.n = 1;
|
|
457
|
+
return new webpack.Compiler(ctx.webpackConfig).context({});
|
|
458
|
+
case 1:
|
|
459
|
+
context = _context2.v;
|
|
460
|
+
_ctx$getDoraConfigSer = ctx.getDoraConfigServiceConfig(), publicPath = _ctx$getDoraConfigSer.publicPath;
|
|
461
|
+
dynamicHtml = new ModuleHtmlMultiple();
|
|
462
|
+
moduleNames = (ctx.getDoraConfig().multiple || []).map(function (module) {
|
|
463
|
+
return module.name;
|
|
464
|
+
});
|
|
465
|
+
webpack.collectAssetUrls(context.compiler, function (assetList) {
|
|
466
|
+
dynamicHtml.setAssetList(assetList);
|
|
467
|
+
}, {
|
|
468
|
+
hostname: ctx.getDoraConfigServiceConfig().host || 'localhost',
|
|
469
|
+
port: ctx.getDoraConfigServiceConfig().port || 3000
|
|
470
|
+
});
|
|
471
|
+
origSetup = ctx.devServerConfig.setupMiddlewares;
|
|
472
|
+
ctx.updateDevServerConfig({
|
|
473
|
+
setupMiddlewares: function setupMiddlewares(middlewares, server) {
|
|
474
|
+
middlewares.unshift({
|
|
475
|
+
name: 'multi-entry-html',
|
|
476
|
+
middleware: function middleware(req, res, next) {
|
|
477
|
+
var targetModuleName = moduleNames.find(function (moduleName) {
|
|
478
|
+
return new RegExp("^".concat(utils.uri.pathJoin(publicPath, moduleName === 'index' ? '' : moduleName), "(/)?$")).test(req.url || '');
|
|
479
|
+
});
|
|
480
|
+
if (targetModuleName) {
|
|
481
|
+
dynamicHtml.getModuleHtml(targetModuleName).then(function (html) {
|
|
482
|
+
res.setHeader('Content-Type', 'text/html; charset=utf-8');
|
|
483
|
+
res.end(html);
|
|
484
|
+
}).catch(function (err) {
|
|
485
|
+
res.statusCode = 500;
|
|
486
|
+
res.end("Error generating HTML for module ".concat(targetModuleName, ": ").concat(err));
|
|
487
|
+
});
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
next();
|
|
491
|
+
}
|
|
492
|
+
});
|
|
493
|
+
return origSetup ? origSetup(middlewares, server) : middlewares;
|
|
494
|
+
}
|
|
495
|
+
});
|
|
496
|
+
_context2.n = 2;
|
|
497
|
+
return context.server(ctx.devServerConfig);
|
|
498
|
+
case 2:
|
|
499
|
+
return _context2.a(2);
|
|
500
|
+
}
|
|
501
|
+
}, _callee2);
|
|
502
|
+
}));
|
|
503
|
+
return function serverMultipleBase(_x2) {
|
|
504
|
+
return _ref2.apply(this, arguments);
|
|
505
|
+
};
|
|
506
|
+
}();
|
|
507
|
+
var serverBaseWorkfolw = function serverBaseWorkfolw(workflow) {
|
|
508
|
+
workflow.use(webpack.webpackPlainMw());
|
|
509
|
+
workflow.use(webpack.webpackDevtoolMw());
|
|
510
|
+
workflow.use(webpack.webpackExternalsMw());
|
|
511
|
+
workflow.use(webpack.webpackResolveLoaderMw());
|
|
512
|
+
workflow.use(webpack.webpackResolveMw());
|
|
513
|
+
workflow.use(webpack.webpackReactModuleMw());
|
|
514
|
+
workflow.use(webpack.webpackMultipleReactPluginMw());
|
|
515
|
+
workflow.use(webpack.webpackDevServerMw());
|
|
516
|
+
workflow.use(webpack.webpackLogLevelMw('warn'));
|
|
285
517
|
};
|
|
286
518
|
|
|
287
|
-
var buildSingle = function
|
|
288
|
-
|
|
289
|
-
var ctx, res,
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
519
|
+
var buildSingle = /*#__PURE__*/function () {
|
|
520
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
521
|
+
var ctx, res, _ref2, err, stats, _stats$compilation;
|
|
522
|
+
return _regenerator().w(function (_context) {
|
|
523
|
+
while (1) switch (_context.n) {
|
|
524
|
+
case 0:
|
|
525
|
+
_context.n = 1;
|
|
526
|
+
return getBuildCtx(configCtx, envParams);
|
|
527
|
+
case 1:
|
|
528
|
+
ctx = _context.v;
|
|
529
|
+
_context.n = 2;
|
|
530
|
+
return buildBase(ctx);
|
|
531
|
+
case 2:
|
|
532
|
+
res = _context.v;
|
|
533
|
+
_ref2 = res || {}, err = _ref2.err, stats = _ref2.stats;
|
|
534
|
+
if (!err) {
|
|
535
|
+
_context.n = 3;
|
|
536
|
+
break;
|
|
537
|
+
}
|
|
297
538
|
helper.cLog.error('build', 'build_error', 'webpack构建失败,捕获到错误');
|
|
298
539
|
console.error(err);
|
|
299
|
-
return
|
|
300
|
-
|
|
301
|
-
|
|
540
|
+
return _context.a(2);
|
|
541
|
+
case 3:
|
|
542
|
+
if (!(stats !== null && stats !== void 0 && stats.hasErrors())) {
|
|
543
|
+
_context.n = 4;
|
|
544
|
+
break;
|
|
545
|
+
}
|
|
302
546
|
helper.cLog.error('build', 'build_error', 'webpack构建失败,捕获到状态错误');
|
|
303
547
|
stats === null || stats === void 0 || (_stats$compilation = stats.compilation) === null || _stats$compilation === void 0 || (_stats$compilation = _stats$compilation.errors) === null || _stats$compilation === void 0 || _stats$compilation.forEach(function (error) {
|
|
304
548
|
console.error(error);
|
|
305
549
|
});
|
|
306
|
-
return
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
return $error($boundEx);
|
|
550
|
+
return _context.a(2);
|
|
551
|
+
case 4:
|
|
552
|
+
helper.cLog.info('build', 'build_success', 'webpack构建成功');
|
|
553
|
+
case 5:
|
|
554
|
+
return _context.a(2);
|
|
312
555
|
}
|
|
313
|
-
},
|
|
314
|
-
});
|
|
315
|
-
|
|
556
|
+
}, _callee);
|
|
557
|
+
}));
|
|
558
|
+
return function buildSingle(_x, _x2) {
|
|
559
|
+
return _ref.apply(this, arguments);
|
|
560
|
+
};
|
|
561
|
+
}();
|
|
316
562
|
|
|
317
|
-
var version = "0.0.
|
|
563
|
+
var version = "0.0.3";
|
|
318
564
|
|
|
319
565
|
/** 生产预设配置 */
|
|
320
566
|
var presetDoracliDefaultConfig = {
|
|
@@ -327,8 +573,9 @@ var presetDoracliDefaultConfig = {
|
|
|
327
573
|
internals: [],
|
|
328
574
|
minimize: true,
|
|
329
575
|
clear: false,
|
|
330
|
-
copy:
|
|
331
|
-
dts: {}
|
|
576
|
+
copy: [],
|
|
577
|
+
dts: {},
|
|
578
|
+
webpackConfig: {}
|
|
332
579
|
};
|
|
333
580
|
|
|
334
581
|
/** 生产预设配置 */
|
|
@@ -337,27 +584,104 @@ var presetDoracliBuildConfig = _objectSpread2(_objectSpread2({}, presetDoracliDe
|
|
|
337
584
|
clear: true
|
|
338
585
|
});
|
|
339
586
|
|
|
340
|
-
var
|
|
341
|
-
|
|
587
|
+
var getBuilderMutipleCtxList = /*#__PURE__*/function () {
|
|
588
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
589
|
+
var groupList, ctxList, i, groupConfigCtx, workflow, ctx;
|
|
590
|
+
return _regenerator().w(function (_context) {
|
|
591
|
+
while (1) switch (_context.n) {
|
|
592
|
+
case 0:
|
|
593
|
+
groupList = webpack.splitDoraConfig(configCtx);
|
|
594
|
+
ctxList = [];
|
|
595
|
+
i = 0;
|
|
596
|
+
case 1:
|
|
597
|
+
if (!(i < groupList.length)) {
|
|
598
|
+
_context.n = 4;
|
|
599
|
+
break;
|
|
600
|
+
}
|
|
601
|
+
groupConfigCtx = groupList[i];
|
|
602
|
+
workflow = helper.configCtxWorkflow(new webpack.Ctx(groupConfigCtx));
|
|
603
|
+
workflow.use(webpack.envParamsMw(envParams));
|
|
604
|
+
workflow.use(webpack.multipleToInOutMw());
|
|
605
|
+
builderBaseWorkfolw(workflow);
|
|
606
|
+
_context.n = 2;
|
|
607
|
+
return workflow.getResult();
|
|
608
|
+
case 2:
|
|
609
|
+
ctx = _context.v;
|
|
610
|
+
ctxList.push(ctx);
|
|
611
|
+
case 3:
|
|
612
|
+
i++;
|
|
613
|
+
_context.n = 1;
|
|
614
|
+
break;
|
|
615
|
+
case 4:
|
|
616
|
+
return _context.a(2, ctxList);
|
|
617
|
+
}
|
|
618
|
+
}, _callee);
|
|
619
|
+
}));
|
|
620
|
+
return function getBuilderMutipleCtxList(_x, _x2) {
|
|
621
|
+
return _ref.apply(this, arguments);
|
|
622
|
+
};
|
|
623
|
+
}();
|
|
624
|
+
|
|
625
|
+
var buildMultiple = /*#__PURE__*/function () {
|
|
626
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
627
|
+
var ctxList, i, ctx;
|
|
628
|
+
return _regenerator().w(function (_context) {
|
|
629
|
+
while (1) switch (_context.n) {
|
|
630
|
+
case 0:
|
|
631
|
+
_context.n = 1;
|
|
632
|
+
return getBuilderMutipleCtxList(configCtx, envParams);
|
|
633
|
+
case 1:
|
|
634
|
+
ctxList = _context.v;
|
|
635
|
+
helper.cLog.log('build', 'info', "\u5171".concat(ctxList.length, "\u4E2A\u4EFB\u52A1\uFF0C\u6B63\u5728\u542F\u52A8\u4E2D..."));
|
|
636
|
+
i = 0;
|
|
637
|
+
case 2:
|
|
638
|
+
if (!(i < ctxList.length)) {
|
|
639
|
+
_context.n = 5;
|
|
640
|
+
break;
|
|
641
|
+
}
|
|
642
|
+
ctx = ctxList[i];
|
|
643
|
+
_context.n = 3;
|
|
644
|
+
return buildMultipleBase(ctx);
|
|
645
|
+
case 3:
|
|
646
|
+
helper.cLog.log('build', 'success', "\u7B2C".concat(i + 1, "\u4E2A\u4EFB\u52A1\u6784\u5EFA\u7ED3\u675F"));
|
|
647
|
+
case 4:
|
|
648
|
+
i++;
|
|
649
|
+
_context.n = 2;
|
|
650
|
+
break;
|
|
651
|
+
case 5:
|
|
652
|
+
helper.cLog.info('build', 'all_end', '多任务构建结束');
|
|
653
|
+
case 6:
|
|
654
|
+
return _context.a(2);
|
|
655
|
+
}
|
|
656
|
+
}, _callee);
|
|
657
|
+
}));
|
|
658
|
+
return function buildMultiple(_x, _x2) {
|
|
659
|
+
return _ref.apply(this, arguments);
|
|
660
|
+
};
|
|
661
|
+
}();
|
|
662
|
+
|
|
663
|
+
var buildEntry = /*#__PURE__*/function () {
|
|
664
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(cmd) {
|
|
342
665
|
var envParams, configCtx;
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
} catch ($boundEx) {
|
|
356
|
-
return $error($boundEx);
|
|
666
|
+
return _regenerator().w(function (_context) {
|
|
667
|
+
while (1) switch (_context.n) {
|
|
668
|
+
case 0:
|
|
669
|
+
envParams = {
|
|
670
|
+
action: 'build',
|
|
671
|
+
workRootDir: process.cwd()
|
|
672
|
+
};
|
|
673
|
+
_context.n = 1;
|
|
674
|
+
return getConfigCtx(envParams, cmd, presetDoracliBuildConfig);
|
|
675
|
+
case 1:
|
|
676
|
+
configCtx = _context.v;
|
|
677
|
+
return _context.a(2, buildMultiple(configCtx, envParams));
|
|
357
678
|
}
|
|
358
|
-
},
|
|
359
|
-
});
|
|
360
|
-
|
|
679
|
+
}, _callee);
|
|
680
|
+
}));
|
|
681
|
+
return function buildEntry(_x) {
|
|
682
|
+
return _ref.apply(this, arguments);
|
|
683
|
+
};
|
|
684
|
+
}();
|
|
361
685
|
|
|
362
686
|
/** 生产预设配置 */
|
|
363
687
|
var presetDoracliDevConfig = _objectSpread2(_objectSpread2({}, presetDoracliDefaultConfig), {}, {
|
|
@@ -365,115 +689,164 @@ var presetDoracliDevConfig = _objectSpread2(_objectSpread2({}, presetDoracliDefa
|
|
|
365
689
|
minimize: false
|
|
366
690
|
});
|
|
367
691
|
|
|
368
|
-
var devEntry = function
|
|
369
|
-
|
|
692
|
+
var devEntry = /*#__PURE__*/function () {
|
|
693
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(cmd) {
|
|
370
694
|
var envParams, configCtx;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
} catch ($boundEx) {
|
|
384
|
-
return $error($boundEx);
|
|
695
|
+
return _regenerator().w(function (_context) {
|
|
696
|
+
while (1) switch (_context.n) {
|
|
697
|
+
case 0:
|
|
698
|
+
envParams = {
|
|
699
|
+
action: 'dev',
|
|
700
|
+
workRootDir: process.cwd()
|
|
701
|
+
};
|
|
702
|
+
_context.n = 1;
|
|
703
|
+
return getConfigCtx(envParams, cmd, presetDoracliDevConfig);
|
|
704
|
+
case 1:
|
|
705
|
+
configCtx = _context.v;
|
|
706
|
+
return _context.a(2, buildMultiple(configCtx, envParams));
|
|
385
707
|
}
|
|
386
|
-
},
|
|
387
|
-
});
|
|
388
|
-
|
|
708
|
+
}, _callee);
|
|
709
|
+
}));
|
|
710
|
+
return function devEntry(_x) {
|
|
711
|
+
return _ref.apply(this, arguments);
|
|
712
|
+
};
|
|
713
|
+
}();
|
|
389
714
|
|
|
390
715
|
/** 生产预设配置 */
|
|
391
716
|
var presetDoracliServerConfig = _objectSpread2(_objectSpread2({}, presetDoracliDefaultConfig), {}, {
|
|
392
717
|
clear: false,
|
|
393
718
|
minimize: false,
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
719
|
+
serviceConfig: {
|
|
720
|
+
openBrowser: true,
|
|
721
|
+
static: {
|
|
722
|
+
'./public': '/public'
|
|
723
|
+
},
|
|
724
|
+
port: 3000,
|
|
725
|
+
host: 'localhost',
|
|
726
|
+
publicPath: '/',
|
|
727
|
+
allowedHosts: 'all'
|
|
398
728
|
}
|
|
399
729
|
});
|
|
400
730
|
|
|
401
|
-
var
|
|
402
|
-
var
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return Promise.resolve(webpack.service(ctx.devServerConfig, compiler)).then(function ($await_3) {
|
|
415
|
-
try {
|
|
416
|
-
return $return();
|
|
417
|
-
} catch ($boundEx) {
|
|
418
|
-
return $error($boundEx);
|
|
419
|
-
}
|
|
420
|
-
}, $error);
|
|
421
|
-
} catch ($boundEx) {
|
|
422
|
-
return $error($boundEx);
|
|
731
|
+
var getServerMutipleCtxList = /*#__PURE__*/function () {
|
|
732
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
733
|
+
var groupList, ctxList, i, groupConfigCtx, workflow, ctx;
|
|
734
|
+
return _regenerator().w(function (_context) {
|
|
735
|
+
while (1) switch (_context.n) {
|
|
736
|
+
case 0:
|
|
737
|
+
groupList = webpack.splitDoraConfig(configCtx);
|
|
738
|
+
ctxList = [];
|
|
739
|
+
i = 0;
|
|
740
|
+
case 1:
|
|
741
|
+
if (!(i < groupList.length)) {
|
|
742
|
+
_context.n = 4;
|
|
743
|
+
break;
|
|
423
744
|
}
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
745
|
+
groupConfigCtx = groupList[i];
|
|
746
|
+
workflow = helper.configCtxWorkflow(new webpack.Ctx(groupConfigCtx));
|
|
747
|
+
workflow.use(webpack.envParamsMw(envParams));
|
|
748
|
+
workflow.use(webpack.multipleToInOutMw());
|
|
749
|
+
serverBaseWorkfolw(workflow);
|
|
750
|
+
_context.n = 2;
|
|
751
|
+
return workflow.getResult();
|
|
752
|
+
case 2:
|
|
753
|
+
ctx = _context.v;
|
|
754
|
+
ctxList.push(ctx);
|
|
755
|
+
case 3:
|
|
756
|
+
i++;
|
|
757
|
+
_context.n = 1;
|
|
758
|
+
break;
|
|
759
|
+
case 4:
|
|
760
|
+
return _context.a(2, ctxList);
|
|
427
761
|
}
|
|
428
|
-
},
|
|
429
|
-
});
|
|
430
|
-
|
|
762
|
+
}, _callee);
|
|
763
|
+
}));
|
|
764
|
+
return function getServerMutipleCtxList(_x, _x2) {
|
|
765
|
+
return _ref.apply(this, arguments);
|
|
766
|
+
};
|
|
767
|
+
}();
|
|
431
768
|
|
|
432
|
-
var
|
|
433
|
-
|
|
434
|
-
var
|
|
435
|
-
ctx
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
769
|
+
var serverMultiple = /*#__PURE__*/function () {
|
|
770
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
771
|
+
var _configCtx$getDoraCon;
|
|
772
|
+
var ctxList, getNextPort, i, ctx, port, moduleNames, entryUrl;
|
|
773
|
+
return _regenerator().w(function (_context) {
|
|
774
|
+
while (1) switch (_context.n) {
|
|
775
|
+
case 0:
|
|
776
|
+
_context.n = 1;
|
|
777
|
+
return getServerMutipleCtxList(configCtx, envParams);
|
|
778
|
+
case 1:
|
|
779
|
+
ctxList = _context.v;
|
|
780
|
+
getNextPort = srvTool.portGetter(((_configCtx$getDoraCon = configCtx.getDoraConfig().serviceConfig) === null || _configCtx$getDoraCon === void 0 ? void 0 : _configCtx$getDoraCon.port) || 3000);
|
|
781
|
+
helper.cLog.log('ser', 'info', "\u5171".concat(ctxList.length, "\u4E2A\u4EFB\u52A1\uFF0C\u6B63\u5728\u542F\u52A8\u4E2D..."));
|
|
782
|
+
i = 0;
|
|
783
|
+
case 2:
|
|
784
|
+
if (!(i < ctxList.length)) {
|
|
785
|
+
_context.n = 6;
|
|
786
|
+
break;
|
|
787
|
+
}
|
|
788
|
+
ctx = ctxList[i];
|
|
789
|
+
_context.n = 3;
|
|
790
|
+
return getNextPort();
|
|
791
|
+
case 3:
|
|
792
|
+
port = _context.v;
|
|
793
|
+
ctx.updateDevServerConfig({
|
|
794
|
+
port: port,
|
|
795
|
+
open: false,
|
|
796
|
+
hot: true
|
|
797
|
+
});
|
|
798
|
+
_context.n = 4;
|
|
799
|
+
return serverMultipleBase(ctx);
|
|
800
|
+
case 4:
|
|
801
|
+
moduleNames = (ctx.getDoraConfig().multiple || []).map(function (module) {
|
|
802
|
+
return module.name;
|
|
803
|
+
});
|
|
804
|
+
helper.cLog.log('ser', 'success', "[".concat(moduleNames.join(','), "] \u542F\u52A8\u6210\u529F~"));
|
|
805
|
+
entryUrl = utils.uri.combine({
|
|
806
|
+
protocol: 'http:',
|
|
807
|
+
hostname: 'localhost',
|
|
808
|
+
port: port,
|
|
809
|
+
pathname: utils.uri.pathJoin(ctx.getDoraConfigServiceConfig().publicPath || '/')
|
|
810
|
+
});
|
|
811
|
+
helper.cLog.log('ser', 'link', "\u8BBF\u95EE\u5730\u5740 \u27A9 ".concat(entryUrl));
|
|
812
|
+
case 5:
|
|
813
|
+
i++;
|
|
814
|
+
_context.n = 2;
|
|
815
|
+
break;
|
|
816
|
+
case 6:
|
|
817
|
+
helper.cLog.info('ser', 'success', "\u6240\u6709\u670D\u52A1\u542F\u52A8\u6210\u529F~");
|
|
818
|
+
case 7:
|
|
819
|
+
return _context.a(2);
|
|
443
820
|
}
|
|
444
|
-
},
|
|
445
|
-
});
|
|
446
|
-
|
|
821
|
+
}, _callee);
|
|
822
|
+
}));
|
|
823
|
+
return function serverMultiple(_x, _x2) {
|
|
824
|
+
return _ref.apply(this, arguments);
|
|
825
|
+
};
|
|
826
|
+
}();
|
|
447
827
|
|
|
448
|
-
var serverEntry = function
|
|
449
|
-
|
|
450
|
-
var envParams, configCtx
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
try {
|
|
464
|
-
cdnConfig = $await_2 || {};
|
|
465
|
-
configCtx.setCdnConfig(cdnConfig);
|
|
466
|
-
return $return(serverSingle(configCtx, envParams));
|
|
467
|
-
} catch ($boundEx) {
|
|
468
|
-
return $error($boundEx);
|
|
469
|
-
}
|
|
470
|
-
}, $error);
|
|
471
|
-
} catch ($boundEx) {
|
|
472
|
-
return $error($boundEx);
|
|
828
|
+
var serverEntry = /*#__PURE__*/function () {
|
|
829
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(cmd) {
|
|
830
|
+
var envParams, configCtx;
|
|
831
|
+
return _regenerator().w(function (_context) {
|
|
832
|
+
while (1) switch (_context.n) {
|
|
833
|
+
case 0:
|
|
834
|
+
envParams = {
|
|
835
|
+
action: 'server',
|
|
836
|
+
workRootDir: process.cwd()
|
|
837
|
+
};
|
|
838
|
+
_context.n = 1;
|
|
839
|
+
return getConfigCtx(envParams, cmd, presetDoracliServerConfig);
|
|
840
|
+
case 1:
|
|
841
|
+
configCtx = _context.v;
|
|
842
|
+
return _context.a(2, serverMultiple(configCtx, envParams));
|
|
473
843
|
}
|
|
474
|
-
},
|
|
475
|
-
});
|
|
476
|
-
|
|
844
|
+
}, _callee);
|
|
845
|
+
}));
|
|
846
|
+
return function serverEntry(_x) {
|
|
847
|
+
return _ref.apply(this, arguments);
|
|
848
|
+
};
|
|
849
|
+
}();
|
|
477
850
|
|
|
478
851
|
var childCommands = [{
|
|
479
852
|
command: 'server',
|
|
@@ -537,9 +910,48 @@ var commandOptions = {
|
|
|
537
910
|
childCommands: childCommands
|
|
538
911
|
};
|
|
539
912
|
|
|
913
|
+
var serverSingle = /*#__PURE__*/function () {
|
|
914
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(configCtx, envParams) {
|
|
915
|
+
var workflow, ctx;
|
|
916
|
+
return _regenerator().w(function (_context) {
|
|
917
|
+
while (1) switch (_context.n) {
|
|
918
|
+
case 0:
|
|
919
|
+
workflow = helper.configCtxWorkflow(new webpack.Ctx(configCtx));
|
|
920
|
+
workflow.use(webpack.envParamsMw(envParams));
|
|
921
|
+
workflow.use(webpack.webpackEntryWholeMw());
|
|
922
|
+
workflow.use(webpack.webpackOutputMw());
|
|
923
|
+
serverBaseWorkfolw(workflow);
|
|
924
|
+
workflow.use(webpack.webpackHtmlPluginMw());
|
|
925
|
+
_context.n = 1;
|
|
926
|
+
return workflow.getResult();
|
|
927
|
+
case 1:
|
|
928
|
+
ctx = _context.v;
|
|
929
|
+
_context.n = 2;
|
|
930
|
+
return serverBase(ctx);
|
|
931
|
+
case 2:
|
|
932
|
+
helper.cLog.info('ser', 'success', 'webpack 服务启动成功~');
|
|
933
|
+
case 3:
|
|
934
|
+
return _context.a(2);
|
|
935
|
+
}
|
|
936
|
+
}, _callee);
|
|
937
|
+
}));
|
|
938
|
+
return function serverSingle(_x, _x2) {
|
|
939
|
+
return _ref.apply(this, arguments);
|
|
940
|
+
};
|
|
941
|
+
}();
|
|
942
|
+
|
|
540
943
|
exports.buildBase = buildBase;
|
|
944
|
+
exports.buildMultipleBase = buildMultipleBase;
|
|
541
945
|
exports.buildSingle = buildSingle;
|
|
946
|
+
exports.builderBaseWorkfolw = builderBaseWorkfolw;
|
|
542
947
|
exports.childCommands = childCommands;
|
|
543
948
|
exports.commandOptions = commandOptions;
|
|
949
|
+
exports.devEntry = devEntry;
|
|
950
|
+
exports.getBuildCtx = getBuildCtx;
|
|
951
|
+
exports.getConfigCtx = getConfigCtx;
|
|
952
|
+
exports.getServerCtx = getServerCtx;
|
|
953
|
+
exports.getServerMutipleCtxList = getServerMutipleCtxList;
|
|
544
954
|
exports.serverBase = serverBase;
|
|
955
|
+
exports.serverBaseWorkfolw = serverBaseWorkfolw;
|
|
956
|
+
exports.serverMultipleBase = serverMultipleBase;
|
|
545
957
|
exports.serverSingle = serverSingle;
|