crabatool 1.0.458 → 1.0.463
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/package.json +2 -2
- package/tool/compress.js +11 -3
- package/tool/merge/mergeTool.js +4 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "crabatool",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.463",
|
|
4
4
|
"description": "crabatool",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"mergeinitjs": "node ./test/test.js -mergeinitjs",
|
|
14
14
|
"export": "node ./test/test.js -exportgspx -webPath F:/Beefun/srcs",
|
|
15
15
|
"checkjs": "node ./test/test.js -checkjs",
|
|
16
|
-
"mergeFiles": "node ./test/test.js -mergeFiles -modName shell -webPath F:/shell-gerrit/web/src/main/resources/static/shell/ -targetPath F:/shell-gerrit/web/src/main/resources/static/shell/ -inNames skins/craba.min.css,skins/blueSky/skin.css,skins/shell.css,pages/RetailHome.gspx,pages/RetailHome.js,basics/Company.gspx,basics/Company.js,basics/PicUploadForm.gspx,basics/PicUploadForm.js,js/innerNotice.js,Main.gspx,Main.js,js/init.js,js/timingCollector.js,js/help.plug.js -outName F:/shell-gerrit/web/src/main/resources/static/shell/shell.res.js",
|
|
16
|
+
"mergeFiles": "node ./test/test.js -mergeFiles -modName shell -webPath F:/shell-gerrit/web/src/main/resources/static/shell/ -targetPath F:/shell-gerrit/web/src/main/resources/static/shell/ -inNames skins/craba.min.css,skins/blueSky/skin.css,skins/shell.css,pages/RetailHome.gspx,pages/RetailHome.js,basics/Company.gspx,basics/Company.js,basics/PicUploadForm.gspx,basics/PicUploadForm.js,js/innerNotice.js,Main.gspx,Main.js,js/init.js,js/timingCollector.js,js/help.plug.js -outName F:/shell-gerrit/web/src/main/resources/static/shell/shell.res.js -clearCache true",
|
|
17
17
|
"mergeJxcFiles": "node ./test/test.js -mergeFiles -modName jxc -webPath F:/jxc/jxc-web/src/main/resources/static/jxc/ -targetPath F:/jxc/jxc-web/src/main/resources/static/jxc/ -inNames skins/blueSky/skin.css,js/wpsSettings.js,baseinfo/js/qiniu.min.js,baseinfo/js/baseinfo.constant.js,baseinfo/js/grid.ext.js,finance/js/finance.constant.js,baseinfo/js/lockScreen.js -initJs F:/jxc/jxc-web/src/main/resources/static/jxc/js/init.js",
|
|
18
18
|
"mergeSaleFiles": "node ./test/test.js -mergeFiles -modName sale -webPath F:/sale/web/src/main/resources/static/sale/ -targetPath F:/sale/web/src/main/resources/static/sale/ -inNames skins/style/ColorSelectCss.css,skins/blueSky/skin.css,js/jquery.min.js,analysiscloud/js/wpsSettings.js,shopsale/js/payway.js,shopsale/js/billposter.js,eshoporder/eshopsaleorder/RetailHomeData.gspx,eshoporder/eshopsaleorder/RetailHomeData.js -initJs F:/sale/web/src/main/resources/static/sale/js/init.js",
|
|
19
19
|
"checkiconfont": "node ./test/test.js -checkiconfont -webPath F:/crabaevery/www -modName crabaevery -reportHost http://127.0.0.1:9998 -ignoreFiles biconfont/iconfont.js,iconfont/iconfont.js -cssFiles skins/retail/skin.css",
|
package/tool/compress.js
CHANGED
|
@@ -185,9 +185,14 @@ function compressFiles(inNames, outName, initJs) {
|
|
|
185
185
|
});
|
|
186
186
|
|
|
187
187
|
var resContent = `$app.addRes(${JSON.stringify(json)});`;
|
|
188
|
+
var crabaJs = false;
|
|
189
|
+
if (outName && outName.includes('craba.min.js')) {
|
|
190
|
+
initJs = outName;
|
|
191
|
+
crabaJs = true;
|
|
192
|
+
}
|
|
188
193
|
if (initJs) { // 资源包压缩到init.js里面一次性下放
|
|
189
194
|
if (!fs.existsSync(initJs)) {
|
|
190
|
-
console.log('
|
|
195
|
+
console.log('打包失败,打包res资源的js不存在', initJs);
|
|
191
196
|
return;
|
|
192
197
|
}
|
|
193
198
|
var initJsContent = fs.readFileSync(initJs, 'utf-8');
|
|
@@ -197,11 +202,13 @@ function compressFiles(inNames, outName, initJs) {
|
|
|
197
202
|
var endIndex = initJsContent.indexOf(resEnd);
|
|
198
203
|
if (startIndex > -1 && endIndex > -1) {
|
|
199
204
|
initJsContent = initJsContent.slice(0, startIndex + resStart.length) + '\r\n' + resContent + '\r\n' + initJsContent.slice(endIndex);
|
|
205
|
+
} else if (crabaJs) {
|
|
206
|
+
initJsContent = initJsContent + '\r\n' + resStart + '\r\n' + resContent + '\r\n' + resEnd;
|
|
200
207
|
} else {
|
|
201
208
|
initJsContent = resStart + '\r\n' + resContent + '\r\n' + resEnd + '\r\n' + initJsContent;
|
|
202
209
|
}
|
|
203
210
|
fs.writeFileSync(initJs, initJsContent);
|
|
204
|
-
console.log('compressFiles完成,资源包追加
|
|
211
|
+
console.log('compressFiles完成,资源包追加js的方式,路径:', initJs);
|
|
205
212
|
} else {
|
|
206
213
|
utils.mkdirsSync(outName);
|
|
207
214
|
fs.writeFileSync(outName, resContent);
|
|
@@ -262,6 +269,7 @@ function compressCss(inNames, targetCss) {
|
|
|
262
269
|
|
|
263
270
|
console.log('compress完成', inNames, targetCss);
|
|
264
271
|
console.log('\r\n');
|
|
272
|
+
//console.log(content);
|
|
265
273
|
return content;
|
|
266
274
|
}
|
|
267
275
|
|
|
@@ -288,7 +296,7 @@ function compressGspx(filePath) {
|
|
|
288
296
|
xml = removeXMLComments(xml); // 手动替换注释,xml-minifier的removeComments没有生效的
|
|
289
297
|
xml = safeXmlMinify(xml);
|
|
290
298
|
return xml.trim();
|
|
291
|
-
|
|
299
|
+
|
|
292
300
|
/*
|
|
293
301
|
let minified = xmlMinifier.minify(xml, {
|
|
294
302
|
collapseWhitespace: true, // 折叠空白
|
package/tool/merge/mergeTool.js
CHANGED
|
@@ -241,16 +241,18 @@ function compressFile(filePath, options, filePath2, stats) {
|
|
|
241
241
|
// 压缩js或css文件
|
|
242
242
|
if (!options.ignoreCompress) {
|
|
243
243
|
utils.debug("压缩文件:" + filePath);
|
|
244
|
-
content = utils.toUtf8(content);
|
|
245
244
|
if (options.ext == '.js') {
|
|
245
|
+
content = utils.toUtf8(content);
|
|
246
246
|
content = UglifyJS.minify(content, compressOptions).code;
|
|
247
247
|
} else {
|
|
248
|
+
if (content.includes('.name.stop')) {
|
|
249
|
+
console.log(content);
|
|
250
|
+
}
|
|
248
251
|
content = UglifyCss.processString(content, {
|
|
249
252
|
maxLineLen: 1000,
|
|
250
253
|
expandVars: false
|
|
251
254
|
});
|
|
252
255
|
}
|
|
253
|
-
|
|
254
256
|
copyByteToCache(filePath, content, stats, options);
|
|
255
257
|
}
|
|
256
258
|
}
|