npm install -g uglify-js
for file in path/to/js/folder/*.js; do uglifyjs "$file" --stats -c -m -o "$file" echo minified: "$file" done
Save script in Step 2 to a file called ‘minify-js.sh’ and run it using Terminal:
sudo chmod +x minify-js.sh ./minify-js.sh
Modify this code a litte and you can use it with cleancss or other minifier.
This code help me much in deploying my webiste (a static site built with Jekyll). Hope it help someone else.