Minor improvement to translate.js minifier.
Ylian Saint-Hilaire committed
Jun 13, 2020 at 15:38 UTC
ba6d15a79dfa96d16dcd7ee9e7242da2fc4c0130
2 files changed
+15
agents/compressModules.bat
+8
@@ -5,3 +5,11 @@ MD modules_meshcore_min
5
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" compressalljs "modules_meshcmd" "modules_meshcmd_min"
6
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcore.js
7
"..\..\WebSiteCompiler\bin\Debug\WebSiteCompiler.exe" meshcmd.js
8
+
9
+REM del meshcore.min.js
10
+REM %LOCALAPPDATA%\..\Roaming\nvm\v12.13.0\node ..\translate\translate.js minify meshcore.js
11
+REM rename meshcore.js.min meshcore.min.js
12
+
13
+REM del meshcmd.min.js
14
+REM %LOCALAPPDATA%\..\Roaming\nvm\v12.13.0\node ..\translate\translate.js minify meshcmd.js
15
+REM rename meshcmd.js.min meshcmd.min.js
\ No newline at end of file
translate/translate.js
+7
@@ -387,7 +387,11 @@ function startEx(argv) {
387
// Minify the file
388
if (minifyLib = 2) {
389
var inFile = fs.readFileSync(outname).toString()
390
+
391
+ // Perform minification pre-processing
392
if (outname.endsWith('.handlebars') >= 0) { inFile = inFile.split('{{{pluginHandler}}}').join('"{{{pluginHandler}}}"'); }
393
+ if (outname.endsWith('.js')) { inFile = '<script>' + inFile + '</script>'; }
394
+
395
var minifiedOut = minify(inFile, {
396
collapseBooleanAttributes: true,
397
collapseInlineTagWhitespace: false, // This is not good.
@@ -404,6 +408,9 @@ function startEx(argv) {
408
preserveLineBreaks: false,
409
useShortDoctype: true
410
});
411
+
412
+ // Perform minification post-processing
413
+ if (outname.endsWith('.js')) { minifiedOut = minifiedOut.substring(8, minifiedOut.length - 9); }
414
if (outname.endsWith('.handlebars') >= 0) { minifiedOut = minifiedOut.split('"{{{pluginHandler}}}"').join('{{{pluginHandler}}}'); }
415
fs.writeFileSync(outnamemin, minifiedOut, { flag: 'w+' });
416
}