diff --git a/agents/compressModules.bat b/agents/compressModules.bat index 1977b9f1..13c83b29 100644 --- a/agents/compressModules.bat +++ b/agents/compressModules.bat @@ -5,3 +5,11 @@ MD 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\v12.13.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\v12.13.0\node ..\translate\translate.js minify meshcmd.js +REM rename meshcmd.js.min meshcmd.min.js \ No newline at end of file diff --git a/translate/translate.js b/translate/translate.js index 4036ecb9..4f0eb871 100644 --- a/translate/translate.js +++ b/translate/translate.js @@ -387,7 +387,11 @@ function startEx(argv) { // Minify the file if (minifyLib = 2) { var inFile = fs.readFileSync(outname).toString() + + // Perform minification pre-processing if (outname.endsWith('.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); } + if (outname.endsWith('.js')) { inFile = ''; } + var minifiedOut = minify(inFile, { collapseBooleanAttributes: true, collapseInlineTagWhitespace: false, // This is not good. @@ -404,6 +408,9 @@ function startEx(argv) { preserveLineBreaks: false, useShortDoctype: true }); + + // Perform minification post-processing + if (outname.endsWith('.js')) { minifiedOut = minifiedOut.substring(8, minifiedOut.length - 9); } if (outname.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); } fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' }); }