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