@doracli/webpack 0.0.4 → 0.0.5
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 +12 -11
- package/lib/esm/index.js +13 -12
- package/lib/type/index.d.ts +10 -3
- package/package.json +10 -10
package/lib/cjs/index.js
CHANGED
|
@@ -1031,7 +1031,7 @@ var webpackEntryWholeMw = function webpackEntryWholeMw() {
|
|
|
1031
1031
|
* - 1. multiple 变成多入口,多出口 的 entry格式
|
|
1032
1032
|
* - 2. 上下文一定要拆分过
|
|
1033
1033
|
*/
|
|
1034
|
-
var multipleToInOutMw = function multipleToInOutMw() {
|
|
1034
|
+
var multipleToInOutMw = function multipleToInOutMw(outputOptions) {
|
|
1035
1035
|
return function (ctx) {
|
|
1036
1036
|
return function (next) {
|
|
1037
1037
|
return function () {
|
|
@@ -1040,11 +1040,11 @@ var multipleToInOutMw = function multipleToInOutMw() {
|
|
|
1040
1040
|
multiple = _ctx$getDoraConfig.multiple;
|
|
1041
1041
|
if (!multiple || !multiple.length) return next();
|
|
1042
1042
|
var entry = {};
|
|
1043
|
-
var output = {
|
|
1043
|
+
var output = _objectSpread2({
|
|
1044
1044
|
// 使用 hash 避免冲突
|
|
1045
1045
|
filename: '[name]/[chunkhash].js',
|
|
1046
1046
|
path: path.join(ctx.envParams.workRootDir, ((_ctx$configCtx$getDor = ctx.configCtx.getDoraConfig().output) === null || _ctx$configCtx$getDor === void 0 ? void 0 : _ctx$configCtx$getDor.path) || 'dist')
|
|
1047
|
-
};
|
|
1047
|
+
}, outputOptions);
|
|
1048
1048
|
multiple.forEach(function (module) {
|
|
1049
1049
|
if (!module.name) {
|
|
1050
1050
|
helper.cLog.warn('init', 'undefined', 'multiple 配置必须有 name 字段');
|
|
@@ -1123,7 +1123,7 @@ var CompilerStatusPlugin = /*#__PURE__*/function () {
|
|
|
1123
1123
|
var json = stats.toJson({
|
|
1124
1124
|
errors: true
|
|
1125
1125
|
});
|
|
1126
|
-
helper.cLog.error('pack', 'failed', "(".concat(((_json$errors = json.errors) === null || _json$errors === void 0 ? void 0 : _json$errors.length) || 0, " errors, ").concat(time, " ms)"));
|
|
1126
|
+
helper.cLog.error('pack', 'failed', "(".concat(((_json$errors = json.errors) === null || _json$errors === void 0 ? void 0 : _json$errors.length) || 0, " errors, ").concat(time, " ms)"), json.errors);
|
|
1127
1127
|
} else {
|
|
1128
1128
|
var _json$warnings;
|
|
1129
1129
|
var _json = stats.toJson({
|
|
@@ -1277,7 +1277,7 @@ var webpackReactPluginMw = function webpackReactPluginMw(options) {
|
|
|
1277
1277
|
* 替换 React 相关的插件配置
|
|
1278
1278
|
* @returns
|
|
1279
1279
|
*/
|
|
1280
|
-
var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw() {
|
|
1280
|
+
var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw(options) {
|
|
1281
1281
|
return function (ctx) {
|
|
1282
1282
|
return function (next) {
|
|
1283
1283
|
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
@@ -1286,7 +1286,7 @@ var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw() {
|
|
|
1286
1286
|
while (1) switch (_context2.n) {
|
|
1287
1287
|
case 0:
|
|
1288
1288
|
plugins = getReactPluginsPreset(ctx.envParams, {
|
|
1289
|
-
cssFilename: '[name]/[chunkhash].css'
|
|
1289
|
+
cssFilename: (options === null || options === void 0 ? void 0 : options.cssFilename) || '[name]/[chunkhash].css'
|
|
1290
1290
|
});
|
|
1291
1291
|
ctx.updateWebpackConfig({
|
|
1292
1292
|
plugins: plugins
|
|
@@ -1537,7 +1537,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1537
1537
|
* - 单页面应用会拦截到 index
|
|
1538
1538
|
*/
|
|
1539
1539
|
targetModuleName = htmlAssetManager.assetList.find(function (moduleName) {
|
|
1540
|
-
return new RegExp("^".concat(utils.
|
|
1540
|
+
return new RegExp("^".concat(utils.uriPathJoin(htmlAssetManager.publicPath, moduleName === 'index' ? '' : moduleName), "(/)?")).test(req.url || '');
|
|
1541
1541
|
});
|
|
1542
1542
|
if (!targetModuleName) {
|
|
1543
1543
|
_context.n = 2;
|
|
@@ -1574,7 +1574,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1574
1574
|
res.end(htmlStr);
|
|
1575
1575
|
return _context.a(2);
|
|
1576
1576
|
case 2:
|
|
1577
|
-
if (!new RegExp("^".concat(utils.
|
|
1577
|
+
if (!new RegExp("^".concat(utils.uriPathJoin('assetMap'), "(/)?$")).test(req.url || '')) {
|
|
1578
1578
|
_context.n = 3;
|
|
1579
1579
|
break;
|
|
1580
1580
|
}
|
|
@@ -1582,7 +1582,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1582
1582
|
res.end(JSON.stringify(htmlAssetManager.getAssetMap()));
|
|
1583
1583
|
return _context.a(2);
|
|
1584
1584
|
case 3:
|
|
1585
|
-
if (!new RegExp("^".concat(utils.
|
|
1585
|
+
if (!new RegExp("^".concat(utils.uriPathJoin(htmlAssetManager.publicPath), "(/)?$")).test(req.url || '')) {
|
|
1586
1586
|
_context.n = 4;
|
|
1587
1587
|
break;
|
|
1588
1588
|
}
|
|
@@ -1590,9 +1590,9 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1590
1590
|
dynamicHtml = new helper.DynamicHtml();
|
|
1591
1591
|
dynamicHtml.addHeadTags(["\n <style>\n .item {\n margin: 8px 0;\n background-color: #6790ff;\n border-radius: 4px;\n }\n .item a {\n display: block;\n padding: 4px 8px;\n color: #fff;\n font-size: 18px;\n text-decoration: none;\n }\n </style>\n "]);
|
|
1592
1592
|
dynamicHtml.addBodyTags(htmlAssetManager.assetList.map(function (name) {
|
|
1593
|
-
return "<div class=\"item\">\n <a href=\"".concat(utils.
|
|
1593
|
+
return "<div class=\"item\">\n <a href=\"".concat(utils.uriPathJoin(htmlAssetManager.publicPath, name), "\">\n ").concat(name, "\n </a>\n </div>");
|
|
1594
1594
|
}));
|
|
1595
|
-
dynamicHtml.addBodyTags(["<div class=\"item\"><a href=\"".concat(utils.
|
|
1595
|
+
dynamicHtml.addBodyTags(["<div class=\"item\"><a href=\"".concat(utils.uriPathJoin(htmlAssetManager.publicPath, 'assetMap'), "\">\u8D44\u6E90</a></div>")]);
|
|
1596
1596
|
res.end(dynamicHtml.generateHtmlTemplate('server 页面'));
|
|
1597
1597
|
return _context.a(2);
|
|
1598
1598
|
case 4:
|
|
@@ -1723,6 +1723,7 @@ var splitDoraConfig = function splitDoraConfig(configCtx) {
|
|
|
1723
1723
|
});
|
|
1724
1724
|
};
|
|
1725
1725
|
|
|
1726
|
+
exports.webpack = webpack;
|
|
1726
1727
|
exports.Compiler = Compiler;
|
|
1727
1728
|
exports.Ctx = Ctx;
|
|
1728
1729
|
exports.babelLoader = babelLoader;
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import webpack from 'webpack';
|
|
2
|
+
export { default as webpack } from 'webpack';
|
|
2
3
|
import WebpackDevServer from 'webpack-dev-server';
|
|
3
4
|
import { isObject, isArray, noop, get, obj } from '@cclr/lang';
|
|
4
5
|
import openBrowser from '@dorabag/open-browser';
|
|
@@ -11,7 +12,7 @@ import TerserPlugin from 'terser-webpack-plugin';
|
|
|
11
12
|
import HtmlWebpackPlugin from 'html-webpack-plugin';
|
|
12
13
|
import WebpackBundleAnalyzer from 'webpack-bundle-analyzer';
|
|
13
14
|
import WebpackBarPlugin from 'webpackbar';
|
|
14
|
-
import { uri, deepCompareJson } from '@cclr/utils';
|
|
15
|
+
import { uri, uriPathJoin, deepCompareJson } from '@cclr/utils';
|
|
15
16
|
|
|
16
17
|
function _arrayLikeToArray(r, a) {
|
|
17
18
|
(null == a || a > r.length) && (a = r.length);
|
|
@@ -1028,7 +1029,7 @@ var webpackEntryWholeMw = function webpackEntryWholeMw() {
|
|
|
1028
1029
|
* - 1. multiple 变成多入口,多出口 的 entry格式
|
|
1029
1030
|
* - 2. 上下文一定要拆分过
|
|
1030
1031
|
*/
|
|
1031
|
-
var multipleToInOutMw = function multipleToInOutMw() {
|
|
1032
|
+
var multipleToInOutMw = function multipleToInOutMw(outputOptions) {
|
|
1032
1033
|
return function (ctx) {
|
|
1033
1034
|
return function (next) {
|
|
1034
1035
|
return function () {
|
|
@@ -1037,11 +1038,11 @@ var multipleToInOutMw = function multipleToInOutMw() {
|
|
|
1037
1038
|
multiple = _ctx$getDoraConfig.multiple;
|
|
1038
1039
|
if (!multiple || !multiple.length) return next();
|
|
1039
1040
|
var entry = {};
|
|
1040
|
-
var output = {
|
|
1041
|
+
var output = _objectSpread2({
|
|
1041
1042
|
// 使用 hash 避免冲突
|
|
1042
1043
|
filename: '[name]/[chunkhash].js',
|
|
1043
1044
|
path: join(ctx.envParams.workRootDir, ((_ctx$configCtx$getDor = ctx.configCtx.getDoraConfig().output) === null || _ctx$configCtx$getDor === void 0 ? void 0 : _ctx$configCtx$getDor.path) || 'dist')
|
|
1044
|
-
};
|
|
1045
|
+
}, outputOptions);
|
|
1045
1046
|
multiple.forEach(function (module) {
|
|
1046
1047
|
if (!module.name) {
|
|
1047
1048
|
cLog.warn('init', 'undefined', 'multiple 配置必须有 name 字段');
|
|
@@ -1120,7 +1121,7 @@ var CompilerStatusPlugin = /*#__PURE__*/function () {
|
|
|
1120
1121
|
var json = stats.toJson({
|
|
1121
1122
|
errors: true
|
|
1122
1123
|
});
|
|
1123
|
-
cLog.error('pack', 'failed', "(".concat(((_json$errors = json.errors) === null || _json$errors === void 0 ? void 0 : _json$errors.length) || 0, " errors, ").concat(time, " ms)"));
|
|
1124
|
+
cLog.error('pack', 'failed', "(".concat(((_json$errors = json.errors) === null || _json$errors === void 0 ? void 0 : _json$errors.length) || 0, " errors, ").concat(time, " ms)"), json.errors);
|
|
1124
1125
|
} else {
|
|
1125
1126
|
var _json$warnings;
|
|
1126
1127
|
var _json = stats.toJson({
|
|
@@ -1274,7 +1275,7 @@ var webpackReactPluginMw = function webpackReactPluginMw(options) {
|
|
|
1274
1275
|
* 替换 React 相关的插件配置
|
|
1275
1276
|
* @returns
|
|
1276
1277
|
*/
|
|
1277
|
-
var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw() {
|
|
1278
|
+
var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw(options) {
|
|
1278
1279
|
return function (ctx) {
|
|
1279
1280
|
return function (next) {
|
|
1280
1281
|
return /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
|
|
@@ -1283,7 +1284,7 @@ var webpackMultipleReactPluginMw = function webpackMultipleReactPluginMw() {
|
|
|
1283
1284
|
while (1) switch (_context2.n) {
|
|
1284
1285
|
case 0:
|
|
1285
1286
|
plugins = getReactPluginsPreset(ctx.envParams, {
|
|
1286
|
-
cssFilename: '[name]/[chunkhash].css'
|
|
1287
|
+
cssFilename: (options === null || options === void 0 ? void 0 : options.cssFilename) || '[name]/[chunkhash].css'
|
|
1287
1288
|
});
|
|
1288
1289
|
ctx.updateWebpackConfig({
|
|
1289
1290
|
plugins: plugins
|
|
@@ -1534,7 +1535,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1534
1535
|
* - 单页面应用会拦截到 index
|
|
1535
1536
|
*/
|
|
1536
1537
|
targetModuleName = htmlAssetManager.assetList.find(function (moduleName) {
|
|
1537
|
-
return new RegExp("^".concat(
|
|
1538
|
+
return new RegExp("^".concat(uriPathJoin(htmlAssetManager.publicPath, moduleName === 'index' ? '' : moduleName), "(/)?")).test(req.url || '');
|
|
1538
1539
|
});
|
|
1539
1540
|
if (!targetModuleName) {
|
|
1540
1541
|
_context.n = 2;
|
|
@@ -1571,7 +1572,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1571
1572
|
res.end(htmlStr);
|
|
1572
1573
|
return _context.a(2);
|
|
1573
1574
|
case 2:
|
|
1574
|
-
if (!new RegExp("^".concat(
|
|
1575
|
+
if (!new RegExp("^".concat(uriPathJoin('assetMap'), "(/)?$")).test(req.url || '')) {
|
|
1575
1576
|
_context.n = 3;
|
|
1576
1577
|
break;
|
|
1577
1578
|
}
|
|
@@ -1579,7 +1580,7 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1579
1580
|
res.end(JSON.stringify(htmlAssetManager.getAssetMap()));
|
|
1580
1581
|
return _context.a(2);
|
|
1581
1582
|
case 3:
|
|
1582
|
-
if (!new RegExp("^".concat(
|
|
1583
|
+
if (!new RegExp("^".concat(uriPathJoin(htmlAssetManager.publicPath), "(/)?$")).test(req.url || '')) {
|
|
1583
1584
|
_context.n = 4;
|
|
1584
1585
|
break;
|
|
1585
1586
|
}
|
|
@@ -1587,9 +1588,9 @@ var htmlRouteGeneratorMw = /*#__PURE__*/function () {
|
|
|
1587
1588
|
dynamicHtml = new DynamicHtml();
|
|
1588
1589
|
dynamicHtml.addHeadTags(["\n <style>\n .item {\n margin: 8px 0;\n background-color: #6790ff;\n border-radius: 4px;\n }\n .item a {\n display: block;\n padding: 4px 8px;\n color: #fff;\n font-size: 18px;\n text-decoration: none;\n }\n </style>\n "]);
|
|
1589
1590
|
dynamicHtml.addBodyTags(htmlAssetManager.assetList.map(function (name) {
|
|
1590
|
-
return "<div class=\"item\">\n <a href=\"".concat(
|
|
1591
|
+
return "<div class=\"item\">\n <a href=\"".concat(uriPathJoin(htmlAssetManager.publicPath, name), "\">\n ").concat(name, "\n </a>\n </div>");
|
|
1591
1592
|
}));
|
|
1592
|
-
dynamicHtml.addBodyTags(["<div class=\"item\"><a href=\"".concat(
|
|
1593
|
+
dynamicHtml.addBodyTags(["<div class=\"item\"><a href=\"".concat(uriPathJoin(htmlAssetManager.publicPath, 'assetMap'), "\">\u8D44\u6E90</a></div>")]);
|
|
1593
1594
|
res.end(dynamicHtml.generateHtmlTemplate('server 页面'));
|
|
1594
1595
|
return _context.a(2);
|
|
1595
1596
|
case 4:
|
package/lib/type/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import * as http from 'http';
|
|
2
1
|
import * as webpack from 'webpack';
|
|
3
2
|
import webpack__default, { Configuration, Stats, Compiler as Compiler$1 } from 'webpack';
|
|
3
|
+
export { Compilation, ExternalModule, Module, Compiler as WebpackCompiler, WebpackPluginInstance, default as webpack } from 'webpack';
|
|
4
|
+
import * as http from 'http';
|
|
4
5
|
import WebpackDevServer, { Configuration as Configuration$1 } from 'webpack-dev-server';
|
|
5
6
|
import { TPlainObject, TAny } from '@cclr/lang';
|
|
6
7
|
import { CompilerBase, ConfigCtx, HtmlAssetManager } from '@doracli/helper';
|
|
@@ -164,7 +165,10 @@ declare const webpackEntryWholeMw: () => TOnionFun<Ctx>;
|
|
|
164
165
|
* - 1. multiple 变成多入口,多出口 的 entry格式
|
|
165
166
|
* - 2. 上下文一定要拆分过
|
|
166
167
|
*/
|
|
167
|
-
declare const multipleToInOutMw: (
|
|
168
|
+
declare const multipleToInOutMw: (outputOptions?: {
|
|
169
|
+
/** default: [name]/[chunkhash].js */
|
|
170
|
+
filename: string;
|
|
171
|
+
}) => TOnionFun<Ctx>;
|
|
168
172
|
|
|
169
173
|
/**
|
|
170
174
|
* webpack dev server 配置 中间件
|
|
@@ -200,7 +204,10 @@ declare const webpackReactPluginMw: (options?: IReactPluginsPresetOptions) => TO
|
|
|
200
204
|
* 替换 React 相关的插件配置
|
|
201
205
|
* @returns
|
|
202
206
|
*/
|
|
203
|
-
declare const webpackMultipleReactPluginMw: (
|
|
207
|
+
declare const webpackMultipleReactPluginMw: (options?: {
|
|
208
|
+
/** default: [name]/[chunkhash].css */
|
|
209
|
+
cssFilename?: string;
|
|
210
|
+
}) => TOnionFun<Ctx>;
|
|
204
211
|
/**
|
|
205
212
|
* 添加 HtmlWebpackPlugin 插件配置
|
|
206
213
|
* @returns
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@doracli/webpack",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "use webpack",
|
|
5
5
|
"author": "cclr <18843152354@163.com>",
|
|
6
6
|
"homepage": "",
|
|
@@ -25,21 +25,21 @@
|
|
|
25
25
|
"scripts": {
|
|
26
26
|
"test": "vitest",
|
|
27
27
|
"g:test": "vitest run",
|
|
28
|
-
"build": "
|
|
28
|
+
"build": "drr build"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@dorabag/open-browser": "^1.0.16"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"@cclr/lang": "^0.1.
|
|
35
|
-
"@cclr/utils": "^0.1.
|
|
34
|
+
"@cclr/lang": "^0.1.49",
|
|
35
|
+
"@cclr/utils": "^0.1.49",
|
|
36
36
|
"@dorabag/config-loader": "^1.0.16",
|
|
37
37
|
"@dorabag/file-pro": "^1.0.10",
|
|
38
38
|
"@dorabag/open-browser": "^1.0.7",
|
|
39
39
|
"@dorabag/srv-tool": "^1.0.16",
|
|
40
|
-
"@doracli/helper": "^0.0.
|
|
41
|
-
"@doracli/preset-babel": "^0.0.
|
|
42
|
-
"@doracli/type": "^0.0.
|
|
40
|
+
"@doracli/helper": "^0.0.5",
|
|
41
|
+
"@doracli/preset-babel": "^0.0.5",
|
|
42
|
+
"@doracli/type": "^0.0.5",
|
|
43
43
|
"babel-loader": "^10.0.0",
|
|
44
44
|
"css-loader": "^7.1.2",
|
|
45
45
|
"html-webpack-plugin": "^5.6.5",
|
|
@@ -50,14 +50,14 @@
|
|
|
50
50
|
"postcss": "^8.5.6",
|
|
51
51
|
"postcss-loader": "^8.2.0",
|
|
52
52
|
"postcss-preset-env": "^10.5.0",
|
|
53
|
-
"sass": "^1.97.
|
|
53
|
+
"sass": "^1.97.1",
|
|
54
54
|
"sass-loader": "^16.0.6",
|
|
55
55
|
"style-loader": "^4.0.0",
|
|
56
56
|
"terser-webpack-plugin": "^5.3.16",
|
|
57
|
-
"webpack": "^5.104.
|
|
57
|
+
"webpack": "^5.104.1",
|
|
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": "ac4c6829b2cec621ecf66b6324843773e8b5141f"
|
|
63
63
|
}
|