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