1
0
mirror of https://github.com/Tygs/0bin.git synced 2023-08-10 21:13:00 +03:00
0bin/compress.sh

57 lines
1.5 KiB
Bash
Raw Normal View History

2012-05-17 13:13:40 +04:00
#! /bin/bash
2020-08-14 19:18:17 +03:00
command -v "yui-compressor" >/dev/null 2>&1 || {
echo >&2 "Error: this script requires the command 'yui-compressor' to be available"
exit 1
}
2012-05-17 13:13:40 +04:00
2020-08-14 19:18:17 +03:00
command -v "uglifyjs" >/dev/null 2>&1 || {
echo >&2 "Error: this script requires the command 'uglifyjs' to be available"
exit 1
}
CURDIR=$(dirname $(readlink -f $0))
2012-05-17 13:13:40 +04:00
STATICDIR=$CURDIR'/zerobin/static/'
CSSDIR=$STATICDIR'css/'
JSDIR=$STATICDIR'js/'
2020-08-14 19:18:17 +03:00
MAIN_JS_OUTPUT=$JSDIR"main.min.js"
ADDITIONAL_JS_OUTPUT=$JSDIR"additional.min.js"
2012-05-17 13:13:40 +04:00
CSS_OUTPUT=$CSSDIR"style.min.css"
2020-08-14 19:18:17 +03:00
cat /dev/null >$CSS_OUTPUT
2012-05-17 13:13:40 +04:00
echo "Compressing CSS..."
2020-08-14 19:18:17 +03:00
echo $'\n''/* Prettify */' >>$CSS_OUTPUT
cat $CSSDIR'prettify.css' >>$CSS_OUTPUT
echo $'\n''/* Desert prettify theme */' >>$CSS_OUTPUT
cat $CSSDIR'desert.css' >>$CSS_OUTPUT
echo $'\n''/* Bootswatch bootstrap theme */' >>$CSS_OUTPUT
yui-compressor $CSSDIR'bootswatch.4.5.css' >>$CSS_OUTPUT
echo $'\n''/* Our own CSS */' >>$CSS_OUTPUT
yui-compressor $CSSDIR'style.css' >>$CSS_OUTPUT
2012-05-17 13:13:40 +04:00
echo "Compressing JS..."
2020-08-14 19:18:17 +03:00
cat /dev/null >$MAIN_JS_OUTPUT
echo $'\n''/* Vue */' >>$MAIN_JS_OUTPUT
uglifyjs $JSDIR'vue.js' >>$MAIN_JS_OUTPUT
2012-05-17 13:13:40 +04:00
# strip the "use strict" statement because it will apply to all the files
# TODO: file a bug report to SJCL to invite them to use the function syntax
2020-08-14 19:18:17 +03:00
echo $'\n''/* SJCL */' >>$MAIN_JS_OUTPUT
uglifyjs $JSDIR'sjcl.js' | sed 's/"use strict";//' >>$MAIN_JS_OUTPUT
2012-05-17 13:13:40 +04:00
2020-08-14 19:18:17 +03:00
echo $'\n''/* Our own JS */' >>$MAIN_JS_OUTPUT
uglifyjs $JSDIR'behavior.js' >>$MAIN_JS_OUTPUT
2012-05-17 13:13:40 +04:00
2020-08-14 19:18:17 +03:00
echo $'\n''/* Prettify */' >>$MAIN_JS_OUTPUT
uglifyjs $JSDIR'prettify.min.js' >>$MAIN_JS_OUTPUT
echo "Done"