remove minify-js use html-minifier instead #6357

Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
si458 2024-09-10 20:01:10 +01:00
parent 21206b670c
commit 2b5337329a
3 changed files with 8 additions and 6 deletions

View File

@ -18,7 +18,7 @@ RUN if ! [ -z "$DISABLE_TRANSLATE" ] && [ "$DISABLE_TRANSLATE" != "yes" ] && [ "
fi fi
# install translate/minify modules if need too # install translate/minify modules if need too
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier jsdom minify-js; fi RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral && npm install html-minifier jsdom; fi
# first extractall if need too # first extractall if need too
RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi RUN if [ -z "$DISABLE_MINIFY" ] || [ -z "$DISABLE_TRANSLATE" ]; then cd meshcentral/translate && node translate.js extractall; fi

View File

@ -4143,7 +4143,7 @@ function mainStart() {
else if (config.settings.xmongodb != null) { modules.push('mongojs@3.1.0'); } // Add MongoJS, old driver. else if (config.settings.xmongodb != null) { modules.push('mongojs@3.1.0'); } // Add MongoJS, old driver.
if (nodemailer || ((config.smtp != null) && (config.smtp.name != 'console')) || (config.sendmail != null)) { modules.push('nodemailer@6.9.8'); } // Add SMTP support if (nodemailer || ((config.smtp != null) && (config.smtp.name != 'console')) || (config.sendmail != null)) { modules.push('nodemailer@6.9.8'); } // Add SMTP support
if (sendgrid || (config.sendgrid != null)) { modules.push('@sendgrid/mail'); } // Add SendGrid support if (sendgrid || (config.sendgrid != null)) { modules.push('@sendgrid/mail'); } // Add SendGrid support
if ((args.translate || args.dev) && (Number(process.version.match(/^v(\d+\.\d+)/)[1]) >= 16)) { modules.push('jsdom@22.1.0'); modules.push('esprima@4.0.1'); modules.push('minify-js@0.0.4'); modules.push('html-minifier@4.0.0'); } // Translation support if ((args.translate || args.dev) && (Number(process.version.match(/^v(\d+\.\d+)/)[1]) >= 16)) { modules.push('jsdom@22.1.0'); modules.push('esprima@4.0.1'); modules.push('html-minifier@4.0.0'); } // Translation support
if (typeof config.settings.crowdsec == 'object') { modules.push('@crowdsec/express-bouncer@0.1.0'); } // Add CrowdSec bounser module (https://www.npmjs.com/package/@crowdsec/express-bouncer) if (typeof config.settings.crowdsec == 'object') { modules.push('@crowdsec/express-bouncer@0.1.0'); } // Add CrowdSec bounser module (https://www.npmjs.com/package/@crowdsec/express-bouncer)
if (typeof config.settings.autobackup == 'object') { if (typeof config.settings.autobackup == 'object') {

View File

@ -140,7 +140,7 @@ if (directRun && (NodeJSVer >= 12)) {
// Get things setup // Get things setup
jsdom = require('jsdom'); jsdom = require('jsdom');
esprima = require('esprima'); // https://www.npmjs.com/package/esprima esprima = require('esprima'); // https://www.npmjs.com/package/esprima
if (minifyLib == 1) { minify = require('minify-js'); } if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier
switch (op) { switch (op) {
@ -157,8 +157,8 @@ if (directRun && (NodeJSVer >= 12)) {
if (directRun) { setup(); } if (directRun) { setup(); }
function setup() { function setup() {
var libs = ['jsdom@22.1.0', 'esprima@4.0.1', 'minify-js@0.0.4']; var libs = ['jsdom@22.1.0', 'esprima@4.0.1'];
if (minifyLib == 1) { libs.push('minify-js@0.0.4'); } if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
if (minifyLib == 2) { libs.push('html-minifier@4.0.0'); } if (minifyLib == 2) { libs.push('html-minifier@4.0.0'); }
InstallModules(libs, start); InstallModules(libs, start);
} }
@ -169,7 +169,7 @@ function startEx(argv) {
// Load dependencies // Load dependencies
jsdom = require('jsdom'); jsdom = require('jsdom');
esprima = require('esprima'); // https://www.npmjs.com/package/esprima esprima = require('esprima'); // https://www.npmjs.com/package/esprima
if (minifyLib == 1) { minify = require('minify-js'); } if (minifyLib == 1) { log("minify-js is no longer used, please switch to \"html-minifier\""); process.exit(); return; }
if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier if (minifyLib == 2) { minify = require('html-minifier').minify; } // https://www.npmjs.com/package/html-minifier
var command = null; var command = null;
@ -490,6 +490,8 @@ function startEx(argv) {
outnamemin = (outname.substring(0, outname.length - 5) + '-min.html'); outnamemin = (outname.substring(0, outname.length - 5) + '-min.html');
} else if (outname.endsWith('.htm')) { } else if (outname.endsWith('.htm')) {
outnamemin = (outname.substring(0, outname.length - 4) + '-min.htm'); outnamemin = (outname.substring(0, outname.length - 4) + '-min.htm');
} else if (outname.endsWith('.js')) {
outnamemin = (outname.substring(0, outname.length - 3) + '-min.js');
} else { } else {
outnamemin = (outname, outname + '.min'); outnamemin = (outname, outname + '.min');
} }