mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 04:33:16 +03:00
Improved meshcore/meshcmd minification.
This commit is contained in:
parent
0646dc5cc0
commit
115d80113a
11
agents/compressModules-new.bat
Normal file
11
agents/compressModules-new.bat
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
MD modules_meshcmd_min
|
||||||
|
MD modules_meshcore_min
|
||||||
|
|
||||||
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcmd.js
|
||||||
|
RENAME meshcmd.js.min meshcmd.min.js
|
||||||
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcore.js
|
||||||
|
RENAME meshcore.js.min meshcore.min.js
|
||||||
|
|
||||||
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minifydir C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcore C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcore_min
|
||||||
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minifydir C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcmd C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcmd_min
|
20
agents/compressModules-old.bat
Normal file
20
agents/compressModules-old.bat
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
MD modules_meshcmd_min
|
||||||
|
MD modules_meshcore_min
|
||||||
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcore" "modules_meshcore_min"
|
||||||
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcmd" "modules_meshcmd_min"
|
||||||
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcore.js
|
||||||
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcmd.js
|
||||||
|
|
||||||
|
REM del meshcore.min.js
|
||||||
|
REM %LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcore.js
|
||||||
|
REM rename meshcore.js.min meshcore.min.js
|
||||||
|
|
||||||
|
REM del meshcmd.min.js
|
||||||
|
REM %LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcmd.js
|
||||||
|
REM rename meshcmd.js.min meshcmd.min.js
|
||||||
|
|
||||||
|
REM Minify the translations
|
||||||
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify modules_meshcore\coretranslations.json
|
||||||
|
COPY modules_meshcore\coretranslations.json.min modules_meshcore_min\coretranslations.json
|
||||||
|
DEL modules_meshcore\coretranslations.json.min
|
@ -1,20 +1,9 @@
|
|||||||
@ECHO OFF
|
@ECHO OFF
|
||||||
MD modules_meshcmd_min
|
MD modules_meshcmd_min
|
||||||
MD modules_meshcore_min
|
MD modules_meshcore_min
|
||||||
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcore" "modules_meshcore_min"
|
|
||||||
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcmd" "modules_meshcmd_min"
|
|
||||||
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcore.js
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcore.js
|
||||||
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcmd.js
|
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcmd.js
|
||||||
|
|
||||||
REM del meshcore.min.js
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minifydir C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcore C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcore_min
|
||||||
REM %LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcore.js
|
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minifydir C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcmd C:\Users\Default.DESKTOP-9CGK2DI\Desktop\AmtWebApp\meshcentral\agents\modules_meshcmd_min
|
||||||
REM rename meshcore.js.min meshcore.min.js
|
|
||||||
|
|
||||||
REM del meshcmd.min.js
|
|
||||||
REM %LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify meshcmd.js
|
|
||||||
REM rename meshcmd.js.min meshcmd.min.js
|
|
||||||
|
|
||||||
REM Minify the translations
|
|
||||||
%LOCALAPPDATA%\..\Roaming\nvm\v14.16.0\node ..\translate\translate.js minify modules_meshcore\coretranslations.json
|
|
||||||
COPY modules_meshcore\coretranslations.json.min modules_meshcore_min\coretranslations.json
|
|
||||||
DEL modules_meshcore\coretranslations.json.min
|
|
||||||
|
@ -3,132 +3,132 @@
|
|||||||
"filename": "MeshService.exe",
|
"filename": "MeshService.exe",
|
||||||
"hash": "C0E5DB22DE5DED510C48141D7CFE4807F98B8205D680F5FC8A5D15950F17A1465E0953B7BFA7FAEED72019E765E1C8E1",
|
"hash": "C0E5DB22DE5DED510C48141D7CFE4807F98B8205D680F5FC8A5D15950F17A1465E0953B7BFA7FAEED72019E765E1C8E1",
|
||||||
"size": 3680256,
|
"size": 3680256,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "1985-10-26T08:15:00Z"
|
||||||
},
|
},
|
||||||
"4": {
|
"4": {
|
||||||
"filename": "MeshService64.exe",
|
"filename": "MeshService64.exe",
|
||||||
"hash": "47A927806EDB6DFAC2C79467719FADA0F3625010D551C6D0EA6EA7DB99F088C088E70F562416FC1809B014913CFEA7E0",
|
"hash": "47A927806EDB6DFAC2C79467719FADA0F3625010D551C6D0EA6EA7DB99F088C088E70F562416FC1809B014913CFEA7E0",
|
||||||
"size": 3293184,
|
"size": 3293184,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "1985-10-26T08:15:00Z"
|
||||||
},
|
},
|
||||||
"5": {
|
"5": {
|
||||||
"filename": "meshagent_x86",
|
"filename": "meshagent_x86",
|
||||||
"hash": "E984791A6FB96E06191AEA1D7B3066AB8B2170DC7B8A64D7C9A605CDC79B463541D994587E85E3FD4644359329344734",
|
"hash": "E984791A6FB96E06191AEA1D7B3066AB8B2170DC7B8A64D7C9A605CDC79B463541D994587E85E3FD4644359329344734",
|
||||||
"size": 3650016,
|
"size": 3650016,
|
||||||
"mtime": "2022-08-14T04:42:13Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"6": {
|
"6": {
|
||||||
"filename": "meshagent_x86-64",
|
"filename": "meshagent_x86-64",
|
||||||
"hash": "F6A48178D7BCE798CDF36AC8F49D9650674E38E266DB396A84657EE8FD81BF85FA998456245F2AFE4A20FDD08CD73D2E",
|
"hash": "F6A48178D7BCE798CDF36AC8F49D9650674E38E266DB396A84657EE8FD81BF85FA998456245F2AFE4A20FDD08CD73D2E",
|
||||||
"size": 3724624,
|
"size": 3724624,
|
||||||
"mtime": "2022-08-14T04:42:13Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"7": {
|
"7": {
|
||||||
"filename": "meshagent_mips",
|
"filename": "meshagent_mips",
|
||||||
"hash": "2D913C118114219CF127D9415174645A3F11464A4B13D07A702AFC2A836381C52C4A2854403215DAFF4582C058E8B824",
|
"hash": "2D913C118114219CF127D9415174645A3F11464A4B13D07A702AFC2A836381C52C4A2854403215DAFF4582C058E8B824",
|
||||||
"size": 4522304,
|
"size": 4522304,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"9": {
|
"9": {
|
||||||
"filename": "meshagent_arm",
|
"filename": "meshagent_arm",
|
||||||
"hash": "AD1C9D2A1E468AEB26FD6443581C3CE3F5F8D0A3779BA0EA5BA06C20B5094B095B5F0D0F104B2F26053877E5D005FBAB",
|
"hash": "AD1C9D2A1E468AEB26FD6443581C3CE3F5F8D0A3779BA0EA5BA06C20B5094B095B5F0D0F104B2F26053877E5D005FBAB",
|
||||||
"size": 3132180,
|
"size": 3132180,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"13": {
|
"13": {
|
||||||
"filename": "meshagent_pogo",
|
"filename": "meshagent_pogo",
|
||||||
"hash": "F9E19D72922732BC4C9F84F90CAB380E6A3851B8137A69AB648E1B145BA4F257B5C2C47BBE36CBE62E364328854DD844",
|
"hash": "F9E19D72922732BC4C9F84F90CAB380E6A3851B8137A69AB648E1B145BA4F257B5C2C47BBE36CBE62E364328854DD844",
|
||||||
"size": 3140884,
|
"size": 3140884,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"15": {
|
"15": {
|
||||||
"filename": "meshagent_poky",
|
"filename": "meshagent_poky",
|
||||||
"hash": "DFBF910AC01FE7D8BD2E6649908E0BBE0C553C12ACADB4C73C32BC65BCDCCDF336C39BA47A08C6659F9CB8E475C3677F",
|
"hash": "DFBF910AC01FE7D8BD2E6649908E0BBE0C553C12ACADB4C73C32BC65BCDCCDF336C39BA47A08C6659F9CB8E475C3677F",
|
||||||
"size": 3776024,
|
"size": 3776024,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"16": {
|
"16": {
|
||||||
"filename": "meshagent_osx-x86-64",
|
"filename": "meshagent_osx-x86-64",
|
||||||
"hash": "77A87BCAE3534061CE15060C4F8971074B7AEBC88957CC9FF50BF8F6B234E3AFAE48DCB9A44681A24393F20191BB3DA1",
|
"hash": "77A87BCAE3534061CE15060C4F8971074B7AEBC88957CC9FF50BF8F6B234E3AFAE48DCB9A44681A24393F20191BB3DA1",
|
||||||
"size": 4391904,
|
"size": 4391904,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"18": {
|
"18": {
|
||||||
"filename": "meshagent_poky64",
|
"filename": "meshagent_poky64",
|
||||||
"hash": "0DDF6A2CABC3B1D40CBE9CA4A6EB2103308F228D5332F64E3C9B01A54BC968B0120D2A50B71111D70682435A07577ABD",
|
"hash": "0DDF6A2CABC3B1D40CBE9CA4A6EB2103308F228D5332F64E3C9B01A54BC968B0120D2A50B71111D70682435A07577ABD",
|
||||||
"size": 3478872,
|
"size": 3478872,
|
||||||
"mtime": "2022-08-14T04:42:13Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"19": {
|
"19": {
|
||||||
"filename": "meshagent_x86_nokvm",
|
"filename": "meshagent_x86_nokvm",
|
||||||
"hash": "2AFC43684BD2A2601FAA32BF86F35EAEB29CDD00ABE3BEB3446448EC44E3151E459909569044681C507FE11A82139914",
|
"hash": "2AFC43684BD2A2601FAA32BF86F35EAEB29CDD00ABE3BEB3446448EC44E3151E459909569044681C507FE11A82139914",
|
||||||
"size": 3365188,
|
"size": 3365188,
|
||||||
"mtime": "2022-08-14T04:42:13Z"
|
"mtime": "2022-08-17T21:09:42Z"
|
||||||
},
|
},
|
||||||
"20": {
|
"20": {
|
||||||
"filename": "meshagent_x86-64_nokvm",
|
"filename": "meshagent_x86-64_nokvm",
|
||||||
"hash": "1B198D624FA99E4D6B52AD139A19259B491FA233A2783F5E4C46955A6AD37DDF5053D7F022C95C8F04684CCADFD2CC3D",
|
"hash": "1B198D624FA99E4D6B52AD139A19259B491FA233A2783F5E4C46955A6AD37DDF5053D7F022C95C8F04684CCADFD2CC3D",
|
||||||
"size": 3425584,
|
"size": 3425584,
|
||||||
"mtime": "2022-08-14T04:42:13Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"24": {
|
"24": {
|
||||||
"filename": "meshagent_arm-linaro",
|
"filename": "meshagent_arm-linaro",
|
||||||
"hash": "2F5D211E983A738ABE31A6EAF4B73629FD937D34D5BD8380A420BAB7108040CA2320EADA8F02CFEF763A3C1D0EA8F1A2",
|
"hash": "2F5D211E983A738ABE31A6EAF4B73629FD937D34D5BD8380A420BAB7108040CA2320EADA8F02CFEF763A3C1D0EA8F1A2",
|
||||||
"size": 2194704,
|
"size": 2194704,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"25": {
|
"25": {
|
||||||
"filename": "meshagent_armhf",
|
"filename": "meshagent_armhf",
|
||||||
"hash": "37F717A44CDA07F88D51A5FF9FD220FEA7F61307BD3A418CC8D9E45D9B9EDB1CB069A9398318E0DF2042C4D204657F7D",
|
"hash": "37F717A44CDA07F88D51A5FF9FD220FEA7F61307BD3A418CC8D9E45D9B9EDB1CB069A9398318E0DF2042C4D204657F7D",
|
||||||
"size": 3166784,
|
"size": 3166784,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"27": {
|
"27": {
|
||||||
"filename": "meshagent_armhf2",
|
"filename": "meshagent_armhf2",
|
||||||
"hash": "0AE840520D3B677B9767EA097F3AA5A1E24212529E688200F43935DB1541AB9FB441EC2C7BA8002D45299B04695FD037",
|
"hash": "0AE840520D3B677B9767EA097F3AA5A1E24212529E688200F43935DB1541AB9FB441EC2C7BA8002D45299B04695FD037",
|
||||||
"size": 2837724,
|
"size": 2837724,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"28": {
|
"28": {
|
||||||
"filename": "meshagent_mips24kc",
|
"filename": "meshagent_mips24kc",
|
||||||
"hash": "636B02BD3DD7DED0BB79FAF1B991F7DB89FF23DC1373D3F5E3EA76897B4BF44E8F00A57A3B6C87EBECA8142D9AD5B7B9",
|
"hash": "636B02BD3DD7DED0BB79FAF1B991F7DB89FF23DC1373D3F5E3EA76897B4BF44E8F00A57A3B6C87EBECA8142D9AD5B7B9",
|
||||||
"size": 4163768,
|
"size": 4163768,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"29": {
|
"29": {
|
||||||
"filename": "meshagent_osx-arm-64",
|
"filename": "meshagent_osx-arm-64",
|
||||||
"hash": "D1D8CDAF59105E4E8A753CCC9032F1653AE4DB973765E3E009CA9F352BA7B3C8E487B4F34BB9A0C4A629C29DE55FFF69",
|
"hash": "D1D8CDAF59105E4E8A753CCC9032F1653AE4DB973765E3E009CA9F352BA7B3C8E487B4F34BB9A0C4A629C29DE55FFF69",
|
||||||
"size": 3911880,
|
"size": 3911880,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"30": {
|
"30": {
|
||||||
"filename": "meshagent_freebsd_x86-64",
|
"filename": "meshagent_freebsd_x86-64",
|
||||||
"hash": "4EA888AAD34D104E7FD898E4F331A9A65EB2EB85C7181DADF1E2A5C04B8F22B91B46AEBDC512D714D11D04B4C2B1EA3E",
|
"hash": "4EA888AAD34D104E7FD898E4F331A9A65EB2EB85C7181DADF1E2A5C04B8F22B91B46AEBDC512D714D11D04B4C2B1EA3E",
|
||||||
"size": 4657032,
|
"size": 4657032,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"32": {
|
"32": {
|
||||||
"filename": "meshagent_aarch64",
|
"filename": "meshagent_aarch64",
|
||||||
"hash": "27B50D0696EA3156BA91CBE0EFC2775217A2DCB1BC7AB0B079DCDE52E7D2B3E2A2647FDC6F74087C4D8D748FD90F59AD",
|
"hash": "27B50D0696EA3156BA91CBE0EFC2775217A2DCB1BC7AB0B079DCDE52E7D2B3E2A2647FDC6F74087C4D8D748FD90F59AD",
|
||||||
"size": 3227888,
|
"size": 3227888,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"40": {
|
"40": {
|
||||||
"filename": "meshagent_mipsel24kc",
|
"filename": "meshagent_mipsel24kc",
|
||||||
"hash": "31F3377C4703CFFDD6905FC0EFC96C4BB328474CE62BECB2E79860C5841CA9019EFC6945974847D03797EE49529DDDE0",
|
"hash": "31F3377C4703CFFDD6905FC0EFC96C4BB328474CE62BECB2E79860C5841CA9019EFC6945974847D03797EE49529DDDE0",
|
||||||
"size": 4160072,
|
"size": 4160072,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"41": {
|
"41": {
|
||||||
"filename": "meshagent_aarch64-cortex-a53",
|
"filename": "meshagent_aarch64-cortex-a53",
|
||||||
"hash": "E6D65EB2F8013E4DB811E2E73150C063EB41DF8C9D8321D1F2CA2FAEEA7DBA203032AD4E95A467A0D8FD836E18EE3D0D",
|
"hash": "E6D65EB2F8013E4DB811E2E73150C063EB41DF8C9D8321D1F2CA2FAEEA7DBA203032AD4E95A467A0D8FD836E18EE3D0D",
|
||||||
"size": 3059896,
|
"size": 3059896,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
},
|
},
|
||||||
"10005": {
|
"10005": {
|
||||||
"filename": "meshagent_osx-universal-64",
|
"filename": "meshagent_osx-universal-64",
|
||||||
"hash": "5AB5C0580E9B7B0689C20FD01561997D7B17CA5E14C747E981888C74B8CCECEE827E141ECF6CBD76C5040051C09DE840",
|
"hash": "5AB5C0580E9B7B0689C20FD01561997D7B17CA5E14C747E981888C74B8CCECEE827E141ECF6CBD76C5040051C09DE840",
|
||||||
"size": 8335560,
|
"size": 8335560,
|
||||||
"mtime": "2022-08-14T04:42:12Z"
|
"mtime": "2022-08-17T21:09:41Z"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ function startEx(argv) {
|
|||||||
|
|
||||||
var command = null;
|
var command = null;
|
||||||
if (argv.length > 2) { command = argv[2].toLowerCase(); }
|
if (argv.length > 2) { command = argv[2].toLowerCase(); }
|
||||||
if (['minify', 'check', 'extract', 'extractall', 'translate', 'translateall', 'minifyall', 'merge', 'totext', 'fromtext', 'remove'].indexOf(command) == -1) { command = null; }
|
if (['minify', 'check', 'extract', 'extractall', 'translate', 'translateall', 'minifyall', 'minifydir', 'merge', 'totext', 'fromtext', 'remove'].indexOf(command) == -1) { command = null; }
|
||||||
|
|
||||||
if (directRun) { log('MeshCentral web site translator'); }
|
if (directRun) { log('MeshCentral web site translator'); }
|
||||||
if (command == null) {
|
if (command == null) {
|
||||||
@ -198,6 +198,9 @@ function startEx(argv) {
|
|||||||
log(' MINIFY [sourcefile]');
|
log(' MINIFY [sourcefile]');
|
||||||
log(' Minify a single file.');
|
log(' Minify a single file.');
|
||||||
log('');
|
log('');
|
||||||
|
log(' MINIFYDIR [sourcedir] [destinationdir]');
|
||||||
|
log(' Minify all files in a directory.');
|
||||||
|
log('');
|
||||||
log(' MINIFYALL');
|
log(' MINIFYALL');
|
||||||
log(' Minify the main MeshCentral english web pages.');
|
log(' Minify the main MeshCentral english web pages.');
|
||||||
log('');
|
log('');
|
||||||
@ -342,6 +345,56 @@ function startEx(argv) {
|
|||||||
translate(lang, langFile, sources, subdir);
|
translate(lang, langFile, sources, subdir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (command == 'minifydir') {
|
||||||
|
if (argv.length < 4) { log("Command source and/or destination folders missing."); process.exit(); return; }
|
||||||
|
const sourceFiles = fs.readdirSync(argv[3]);
|
||||||
|
for (var i in sourceFiles) {
|
||||||
|
if (sourceFiles[i].endsWith('.js') || sourceFiles[i].endsWith('.json')) {
|
||||||
|
console.log("Processing " + sourceFiles[i] + "...");
|
||||||
|
const sourceFile = path.join(argv[3], sourceFiles[i]);
|
||||||
|
if (sourceFiles[i].endsWith('.js')) {
|
||||||
|
// Minify the file .js file
|
||||||
|
const destinationFile = path.join(argv[4], sourceFiles[i].substring(0, sourceFiles[i].length - 3) + '.min.js');
|
||||||
|
if (minifyLib = 2) {
|
||||||
|
var inFile = fs.readFileSync(sourceFile).toString();
|
||||||
|
|
||||||
|
// Perform minification pre-processing
|
||||||
|
if (sourceFile.endsWith('.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
|
||||||
|
if (sourceFile.endsWith('.js')) { inFile = '<script>' + inFile + '</script>'; }
|
||||||
|
|
||||||
|
var minifiedOut = minify(inFile, {
|
||||||
|
collapseBooleanAttributes: true,
|
||||||
|
collapseInlineTagWhitespace: false, // This is not good.
|
||||||
|
collapseWhitespace: true,
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyJS: true,
|
||||||
|
removeComments: true,
|
||||||
|
removeOptionalTags: true,
|
||||||
|
removeEmptyAttributes: true,
|
||||||
|
removeAttributeQuotes: true,
|
||||||
|
removeRedundantAttributes: true,
|
||||||
|
removeScriptTypeAttributes: true,
|
||||||
|
removeTagWhitespace: true,
|
||||||
|
preserveLineBreaks: false,
|
||||||
|
useShortDoctype: true
|
||||||
|
});
|
||||||
|
|
||||||
|
// Perform minification post-processing
|
||||||
|
if (sourceFile.endsWith('.js')) { minifiedOut = minifiedOut.substring(8, minifiedOut.length - 9); }
|
||||||
|
if (sourceFile.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
|
||||||
|
fs.writeFileSync(destinationFile, minifiedOut, { flag: 'w+' });
|
||||||
|
}
|
||||||
|
} else if (sourceFiles[i].endsWith('.json')) {
|
||||||
|
// Minify the file .json file
|
||||||
|
const destinationFile = path.join(argv[4], sourceFiles[i]);
|
||||||
|
var inFile = JSON.parse(fs.readFileSync(sourceFile).toString());
|
||||||
|
fs.writeFileSync(destinationFile, JSON.stringify(inFile), { flag: 'w+' });
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (command == 'minifyall') {
|
if (command == 'minifyall') {
|
||||||
for (var i in minifyMeshCentralSourceFiles) {
|
for (var i in minifyMeshCentralSourceFiles) {
|
||||||
var outname = minifyMeshCentralSourceFiles[i];
|
var outname = minifyMeshCentralSourceFiles[i];
|
||||||
|
Loading…
Reference in New Issue
Block a user