[Makefile] Online Concatenate and Compress JavaScript Files
Concatenate and minify/compress JavaScript files via Makefile, curl, and online Google Closure Compiler.
Put this Makefile and js files in the same directory and then type make. After finish, the minified/compressed js file will be named app.min.js in the same directory.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | SOURCE_JS_FILES=$(filter-out %.min.js, $(wildcard *.js)) CONCAT_JS=/tmp/tmp.js MINIFIED_JS=app.min.js minjs: concat curl \ -d compilation_level=SIMPLE_OPTIMIZATIONS \ -d language=ECMASCRIPT5 \ -d output_format=text \ -d output_info=compiled_code \ --data-urlencode "js_code@$(CONCAT_JS)" \ https://closure-compiler.appspot.com/compile \ > $(MINIFIED_JS) concat: @cat $(SOURCE_JS_FILES) > $(CONCAT_JS) |
Tested on: Ubuntu Linux 16.10.
References:
[1] | [Bash] Online Concatenate and Compress JavaScript Files |
[2] | [Makefile] Concetenate and Minify CSS via sed and tr Command |