comparison scripts/minifier/minify.sh @ 12:1596660ddf72

Add minifier script for otr.js and its dependencies
author souliane <souliane@mailoo.org>
date Wed, 03 Sep 2014 19:38:05 +0200
parents
children
comparison
equal deleted inserted replaced
11:4920c8da790b 12:1596660ddf72
1 #!/bin/bash
2
3 # This is a helping script to minify HTML/CSS/JavaScript files
4
5 # Minify JS for Libervia's OTR - https://github.com/arlolra/otr
6 TOOL="yui compressor"
7 OTR_INPUT="otr/dep/bigint.js otr/dep/crypto.js otr/dep/eventemitter.js"
8 OTR_APPEND="otr/otr.min.js"
9 OTR_OUTPUT="otr.min.js"
10
11 rm -f $OTR_OUTPUT
12 if [[ $TOOL = "closure compiler" ]]; then
13 # use https://developers.google.com/closure/compiler/
14 # requires Java 7 SDK + compiler.jar in the current directory
15 echo "Minifying $OTR_INPUT with closure compiler"
16 java -jar compiler.jar --js_output_file=$OTR_OUTPUT $OTR_INPUT
17 else
18 for FILE in $OTR_INPUT; do
19 if [[ $TOOL = "slimit" ]]; then
20 # use https://pypi.python.org/pypi/slimit
21 echo "Minifying $FILE with slimit"
22 slimit $FILE >> $OTR_OUTPUT
23 elif [[ $TOOL = "yui compressor" ]]; then
24 # use https://pypi.python.org/pypi/yuicompressor
25 echo "Minifying $FILE with YUI compressor"
26 yuicompressor -o tmp.js $FILE
27 cat tmp.js >> $OTR_OUTPUT
28 rm -f tmp.js
29 fi
30 done
31 fi
32 cat $OTR_APPEND >> $OTR_OUTPUT
33 echo "The file $OTR_OUTPUT includes:
34 - minified versions of the following otr.js dependencies:
35 $OTR_INPUT
36 The following minification tool has been used: $TOOL
37 - minified version of otr.js taken from the project homepage
38
39 All original files can be retrieved from otr.js repository:
40 https://github.com/arlolra/otr/tree/master/build
41 " > "$OTR_OUTPUT"_README
42
43
44