A function that minifies your javascript files (recursively when --overwrite).
minify-all-js was designed to reduce the size of your js files. By giving it a directory and option --overwrite, minify-all-js will walk through the depth of your folders and minify all the javascript that it sees.
Without --overwrite (the default), minify-all-js does not scan directories recursively and files are renamed to ".min.js". If such a file already exists, then it is overwritten. This prevents to get files like ".min.min.min.js" if you run minify-all-js multiple times.
> npm install -g minify-all-js
> minify-all-js [inputFolder] [outputFolder] [-j] [-m] [-M] [-p] [-o]
> minify-all-js ./node_modules -j -m -M -p
Use CLI options:
inputFolderfolder of input files or current directory if undefinedoutputFolderfolder for output files orinputFolderif undefined-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 and files (default:false)-aor--allto try to compress all files including binary/executable js files without.jsextension (default:false)-oor--overwriteto overwrite original files. IftruethenoutputFolderis ignored (default:false)
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