minify-all-js
A function that minifies your javascript files (recursively).
minify-all-js was designed to reduce the size of your project's node_modules directory. But it can also be used to minify any js files. By giving it a directory, minify-all-js will walk through the depth of your folders and minify all the javascript that it sees.
Installation
> npm install -g minify-all-jsRun CLI
> minify-all-js [folder] [-j] [-m] [-M] [-p]Sample
> minify-all-js ./node_modules -j -m -M -pUse CLI options:
-jor--jsonto compress json files as well. (default:false)-mor--moduleto set terser module option totruefor ES6 files (default:false)-Mor--mangleto set terser mangle option totrue(default:false)-por--packagejsonto clean up extra fields from package.json files (default: false)-aor--allto try to compress all files including binary/executable js files without.jsextension (default: false)
Run programatically
var promise = minifyAllJs([directory], {
compress_json: true, // -j in cli
module: true, // -m in cli
mangle: true, // -M in cli
packagejson: true, // -p in cli
all_js: true // -a in cli
})minifyAllJs function returns a promise