@arkxio/ark-dev-utils 0.1.9 → 0.1.11
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/dist/index.js +37 -19
- package/dist/index.min.js +37 -19
- package/lib/index.js +37 -19
- package/package.json +1 -1
- package/src/ArkWebpackPlugin.js +37 -19
package/dist/index.js
CHANGED
|
@@ -1217,7 +1217,12 @@
|
|
|
1217
1217
|
if (!chunkFiles.has(filename)) return;
|
|
1218
1218
|
|
|
1219
1219
|
// 检查资源内容有效性
|
|
1220
|
-
if (
|
|
1220
|
+
if (
|
|
1221
|
+
!source ||
|
|
1222
|
+
!source.source ||
|
|
1223
|
+
typeof source.source() !== 'string' ||
|
|
1224
|
+
source.source().trim() === ''
|
|
1225
|
+
) {
|
|
1221
1226
|
console.warn(`资源 ${filename} 内容为空或无效,跳过处理`);
|
|
1222
1227
|
return;
|
|
1223
1228
|
}
|
|
@@ -1226,30 +1231,43 @@
|
|
|
1226
1231
|
|
|
1227
1232
|
// 替换逻辑
|
|
1228
1233
|
// /(__webpack_require__\.l)\(url,/g)
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
const
|
|
1234
|
+
// const webpackRequireLPattern = /(__webpack_require__\.l)\(url,/g;
|
|
1235
|
+
// if (webpackRequireLPattern.test(content)) {
|
|
1236
|
+
// verbose('检测到 __webpack_require__.l 模式');
|
|
1237
|
+
// content = content.replace(
|
|
1238
|
+
// webpackRequireLPattern,
|
|
1239
|
+
// `(function(url, done, key, chunkId) {
|
|
1240
|
+
// if (typeof window.ArkConfig !== 'undefined' && window.ArkConfig.cdnHost) {
|
|
1241
|
+
// if (!url.startsWith(window.ArkConfig.cdnHost) && url.startsWith('https://unpkg.com')) {
|
|
1242
|
+
// url = window.ArkConfig.cdnHost + url.slice('https://unpkg.com'.length);
|
|
1243
|
+
// }
|
|
1244
|
+
// }
|
|
1245
|
+
// return $1(url, done, key, chunkId);
|
|
1246
|
+
// })(url,`
|
|
1247
|
+
// );
|
|
1248
|
+
|
|
1249
|
+
let findUnpkgModel = false;
|
|
1250
|
+
const webpackRequireLPatternEval = /"https:\/\/unpkg\.com"/g;
|
|
1251
|
+
if (webpackRequireLPatternEval.test(content)) {
|
|
1252
|
+
webpackRequireLPatternEval.lastIndex = 0;
|
|
1253
|
+
verbose('检测到 转码 unpkg.com 模式');
|
|
1254
|
+
content = content.replace(webpackRequireLPatternEval, 'window.ArkConfig.cdnHost');
|
|
1255
|
+
findUnpkgModel = true;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
const webpackRequireLPattern = /"(https:\/\/unpkg\.com)/g;
|
|
1246
1259
|
if (webpackRequireLPattern.test(content)) {
|
|
1260
|
+
webpackRequireLPattern.lastIndex = 0;
|
|
1261
|
+
findUnpkgModel = true;
|
|
1247
1262
|
verbose('检测到 unpkg.com 模式');
|
|
1248
|
-
content = content.replace(webpackRequireLPattern
|
|
1263
|
+
content = content.replace(webpackRequireLPattern,`window.ArkConfig.cdnHost + "`);
|
|
1264
|
+
}
|
|
1249
1265
|
|
|
1266
|
+
if (findUnpkgModel) {
|
|
1250
1267
|
// 更新资源
|
|
1251
1268
|
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(content));
|
|
1252
1269
|
}
|
|
1270
|
+
|
|
1253
1271
|
});
|
|
1254
1272
|
}
|
|
1255
1273
|
);
|
package/dist/index.min.js
CHANGED
|
@@ -1217,7 +1217,12 @@
|
|
|
1217
1217
|
if (!chunkFiles.has(filename)) return;
|
|
1218
1218
|
|
|
1219
1219
|
// 检查资源内容有效性
|
|
1220
|
-
if (
|
|
1220
|
+
if (
|
|
1221
|
+
!source ||
|
|
1222
|
+
!source.source ||
|
|
1223
|
+
typeof source.source() !== 'string' ||
|
|
1224
|
+
source.source().trim() === ''
|
|
1225
|
+
) {
|
|
1221
1226
|
console.warn(`资源 ${filename} 内容为空或无效,跳过处理`);
|
|
1222
1227
|
return;
|
|
1223
1228
|
}
|
|
@@ -1226,30 +1231,43 @@
|
|
|
1226
1231
|
|
|
1227
1232
|
// 替换逻辑
|
|
1228
1233
|
// /(__webpack_require__\.l)\(url,/g)
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
const
|
|
1234
|
+
// const webpackRequireLPattern = /(__webpack_require__\.l)\(url,/g;
|
|
1235
|
+
// if (webpackRequireLPattern.test(content)) {
|
|
1236
|
+
// verbose('检测到 __webpack_require__.l 模式');
|
|
1237
|
+
// content = content.replace(
|
|
1238
|
+
// webpackRequireLPattern,
|
|
1239
|
+
// `(function(url, done, key, chunkId) {
|
|
1240
|
+
// if (typeof window.ArkConfig !== 'undefined' && window.ArkConfig.cdnHost) {
|
|
1241
|
+
// if (!url.startsWith(window.ArkConfig.cdnHost) && url.startsWith('https://unpkg.com')) {
|
|
1242
|
+
// url = window.ArkConfig.cdnHost + url.slice('https://unpkg.com'.length);
|
|
1243
|
+
// }
|
|
1244
|
+
// }
|
|
1245
|
+
// return $1(url, done, key, chunkId);
|
|
1246
|
+
// })(url,`
|
|
1247
|
+
// );
|
|
1248
|
+
|
|
1249
|
+
let findUnpkgModel = false;
|
|
1250
|
+
const webpackRequireLPatternEval = /"https:\/\/unpkg\.com"/g;
|
|
1251
|
+
if (webpackRequireLPatternEval.test(content)) {
|
|
1252
|
+
webpackRequireLPatternEval.lastIndex = 0;
|
|
1253
|
+
verbose('检测到 转码 unpkg.com 模式');
|
|
1254
|
+
content = content.replace(webpackRequireLPatternEval, 'window.ArkConfig.cdnHost');
|
|
1255
|
+
findUnpkgModel = true;
|
|
1256
|
+
}
|
|
1257
|
+
|
|
1258
|
+
const webpackRequireLPattern = /"(https:\/\/unpkg\.com)/g;
|
|
1246
1259
|
if (webpackRequireLPattern.test(content)) {
|
|
1260
|
+
webpackRequireLPattern.lastIndex = 0;
|
|
1261
|
+
findUnpkgModel = true;
|
|
1247
1262
|
verbose('检测到 unpkg.com 模式');
|
|
1248
|
-
content = content.replace(webpackRequireLPattern
|
|
1263
|
+
content = content.replace(webpackRequireLPattern,`window.ArkConfig.cdnHost + "`);
|
|
1264
|
+
}
|
|
1249
1265
|
|
|
1266
|
+
if (findUnpkgModel) {
|
|
1250
1267
|
// 更新资源
|
|
1251
1268
|
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(content));
|
|
1252
1269
|
}
|
|
1270
|
+
|
|
1253
1271
|
});
|
|
1254
1272
|
}
|
|
1255
1273
|
);
|
package/lib/index.js
CHANGED
|
@@ -1222,7 +1222,12 @@ class ArkWebpackPlugin {
|
|
|
1222
1222
|
if (!chunkFiles.has(filename)) return;
|
|
1223
1223
|
|
|
1224
1224
|
// 检查资源内容有效性
|
|
1225
|
-
if (
|
|
1225
|
+
if (
|
|
1226
|
+
!source ||
|
|
1227
|
+
!source.source ||
|
|
1228
|
+
typeof source.source() !== 'string' ||
|
|
1229
|
+
source.source().trim() === ''
|
|
1230
|
+
) {
|
|
1226
1231
|
console.warn(`资源 ${filename} 内容为空或无效,跳过处理`);
|
|
1227
1232
|
return;
|
|
1228
1233
|
}
|
|
@@ -1231,30 +1236,43 @@ class ArkWebpackPlugin {
|
|
|
1231
1236
|
|
|
1232
1237
|
// 替换逻辑
|
|
1233
1238
|
// /(__webpack_require__\.l)\(url,/g)
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
const
|
|
1239
|
+
// const webpackRequireLPattern = /(__webpack_require__\.l)\(url,/g;
|
|
1240
|
+
// if (webpackRequireLPattern.test(content)) {
|
|
1241
|
+
// verbose('检测到 __webpack_require__.l 模式');
|
|
1242
|
+
// content = content.replace(
|
|
1243
|
+
// webpackRequireLPattern,
|
|
1244
|
+
// `(function(url, done, key, chunkId) {
|
|
1245
|
+
// if (typeof window.ArkConfig !== 'undefined' && window.ArkConfig.cdnHost) {
|
|
1246
|
+
// if (!url.startsWith(window.ArkConfig.cdnHost) && url.startsWith('https://unpkg.com')) {
|
|
1247
|
+
// url = window.ArkConfig.cdnHost + url.slice('https://unpkg.com'.length);
|
|
1248
|
+
// }
|
|
1249
|
+
// }
|
|
1250
|
+
// return $1(url, done, key, chunkId);
|
|
1251
|
+
// })(url,`
|
|
1252
|
+
// );
|
|
1253
|
+
|
|
1254
|
+
let findUnpkgModel = false;
|
|
1255
|
+
const webpackRequireLPatternEval = /"https:\/\/unpkg\.com"/g;
|
|
1256
|
+
if (webpackRequireLPatternEval.test(content)) {
|
|
1257
|
+
webpackRequireLPatternEval.lastIndex = 0;
|
|
1258
|
+
verbose('检测到 转码 unpkg.com 模式');
|
|
1259
|
+
content = content.replace(webpackRequireLPatternEval, 'window.ArkConfig.cdnHost');
|
|
1260
|
+
findUnpkgModel = true;
|
|
1261
|
+
}
|
|
1262
|
+
|
|
1263
|
+
const webpackRequireLPattern = /"(https:\/\/unpkg\.com)/g;
|
|
1251
1264
|
if (webpackRequireLPattern.test(content)) {
|
|
1265
|
+
webpackRequireLPattern.lastIndex = 0;
|
|
1266
|
+
findUnpkgModel = true;
|
|
1252
1267
|
verbose('检测到 unpkg.com 模式');
|
|
1253
|
-
content = content.replace(webpackRequireLPattern
|
|
1268
|
+
content = content.replace(webpackRequireLPattern,`window.ArkConfig.cdnHost + "`);
|
|
1269
|
+
}
|
|
1254
1270
|
|
|
1271
|
+
if (findUnpkgModel) {
|
|
1255
1272
|
// 更新资源
|
|
1256
1273
|
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(content));
|
|
1257
1274
|
}
|
|
1275
|
+
|
|
1258
1276
|
});
|
|
1259
1277
|
}
|
|
1260
1278
|
);
|
package/package.json
CHANGED
package/src/ArkWebpackPlugin.js
CHANGED
|
@@ -42,7 +42,12 @@ export default class ArkWebpackPlugin {
|
|
|
42
42
|
if (!chunkFiles.has(filename)) return;
|
|
43
43
|
|
|
44
44
|
// 检查资源内容有效性
|
|
45
|
-
if (
|
|
45
|
+
if (
|
|
46
|
+
!source ||
|
|
47
|
+
!source.source ||
|
|
48
|
+
typeof source.source() !== 'string' ||
|
|
49
|
+
source.source().trim() === ''
|
|
50
|
+
) {
|
|
46
51
|
console.warn(`资源 ${filename} 内容为空或无效,跳过处理`);
|
|
47
52
|
return;
|
|
48
53
|
}
|
|
@@ -51,30 +56,43 @@ export default class ArkWebpackPlugin {
|
|
|
51
56
|
|
|
52
57
|
// 替换逻辑
|
|
53
58
|
// /(__webpack_require__\.l)\(url,/g)
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
59
|
+
// const webpackRequireLPattern = /(__webpack_require__\.l)\(url,/g;
|
|
60
|
+
// if (webpackRequireLPattern.test(content)) {
|
|
61
|
+
// verbose('检测到 __webpack_require__.l 模式');
|
|
62
|
+
// content = content.replace(
|
|
63
|
+
// webpackRequireLPattern,
|
|
64
|
+
// `(function(url, done, key, chunkId) {
|
|
65
|
+
// if (typeof window.ArkConfig !== 'undefined' && window.ArkConfig.cdnHost) {
|
|
66
|
+
// if (!url.startsWith(window.ArkConfig.cdnHost) && url.startsWith('https://unpkg.com')) {
|
|
67
|
+
// url = window.ArkConfig.cdnHost + url.slice('https://unpkg.com'.length);
|
|
68
|
+
// }
|
|
69
|
+
// }
|
|
70
|
+
// return $1(url, done, key, chunkId);
|
|
71
|
+
// })(url,`
|
|
72
|
+
// );
|
|
73
|
+
|
|
74
|
+
let findUnpkgModel = false;
|
|
75
|
+
const webpackRequireLPatternEval = /"https:\/\/unpkg\.com"/g;
|
|
76
|
+
if (webpackRequireLPatternEval.test(content)) {
|
|
77
|
+
webpackRequireLPatternEval.lastIndex = 0;
|
|
78
|
+
verbose('检测到 转码 unpkg.com 模式');
|
|
79
|
+
content = content.replace(webpackRequireLPatternEval, 'window.ArkConfig.cdnHost');
|
|
80
|
+
findUnpkgModel = true;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const webpackRequireLPattern = /"(https:\/\/unpkg\.com)/g;
|
|
71
84
|
if (webpackRequireLPattern.test(content)) {
|
|
85
|
+
webpackRequireLPattern.lastIndex = 0;
|
|
86
|
+
findUnpkgModel = true;
|
|
72
87
|
verbose('检测到 unpkg.com 模式');
|
|
73
|
-
content = content.replace(webpackRequireLPattern
|
|
88
|
+
content = content.replace(webpackRequireLPattern,`window.ArkConfig.cdnHost + "`);
|
|
89
|
+
}
|
|
74
90
|
|
|
91
|
+
if (findUnpkgModel) {
|
|
75
92
|
// 更新资源
|
|
76
93
|
compilation.updateAsset(filename, new compiler.webpack.sources.RawSource(content));
|
|
77
94
|
}
|
|
95
|
+
|
|
78
96
|
});
|
|
79
97
|
}
|
|
80
98
|
);
|