Build gzip versions when minifying for serving gzipped static content
Build gzip versions when minifying for serving gzipped static content

--- a/css/.gitignore
+++ b/css/.gitignore
@@ -1,2 +1,3 @@
 *.min.css
+*.gz
 

--- a/js/.gitignore
+++ b/js/.gitignore
@@ -1,2 +1,3 @@
 *.min.js
+*.gz
 

--- a/util/minify.sh
+++ b/util/minify.sh
@@ -11,30 +11,56 @@
 #
 
 JSDIR="js"
-COMPRESSORDIR="lib/yuicompressor/build"
-COMPRESSORJAR="yuicompressor-2.4.2.jar"
 
 JSEXT=".js"
 MINEXT=".min.js"
+GZEXT=".gz"
 
 CSSDIR="css"
 CSSEXT=".css"
 MINCSSEXT=".min.css"
 
-rm -f ${JSDIR}/*${MINEXT}
+rm -fv ${JSDIR}/*${MINEXT}
+rm -fv ${CSSDIR}/*${MINCSSEXT}
+rm -fv ${JSDIR}/*${GZEXT}
+rm -fv ${JSDIR}/ext/*${GZEXT}
+rm -fv ${CSSDIR}/*${GZEXT}
+rm -fv ${CSSDIR}/ext/*${GZEXT}
+
+if [ "$1" == "clean" ]; then
+	exit;
+fi
 
 for i in ${JSDIR}/*${JSEXT}; do
 	echo "Minifying ${i}..."
 	JSMODULE="`basename ${i%$JSEXT}`"
-	#java -jar "${COMPRESSORDIR}/${COMPRESSORJAR}" --charset utf-8 -o "${i%$JSEXT}${MINEXT}" "${i}"
 	java -classpath lib/rhino/js.jar:lib/closure/compiler.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o name=${JSMODULE} out=${JSDIR}/${JSMODULE}${MINEXT} baseUrl=${JSDIR} paths.jquery="empty:" exclude="jquery" paths.d3="ext/d3.v2.min" optimize="closure"
 done
 
-rm -f ${CSSDIR}/*${MINCSSEXT}
-
 for i in ${CSSDIR}/*${CSSEXT}; do
 	echo "Minifying ${i}..."
-	#java -jar "${COMPRESSORDIR}/${COMPRESSORJAR}" --charset utf-8 -o "${i%$CSSEXT}${MINCSSEXT}" "${i}"
-	java -classpath lib/rhino/js.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o cssIn=${i} out=${i%$CSSEXT}${MINCSSEXT} optimizeCss="standard"
+	CSSBASE=${i%$CSSEXT}
+	java -classpath lib/rhino/js.jar org.mozilla.javascript.tools.shell.Main lib/requirejs/r.js -o cssIn=${i} out=${CSSBASE}${MINCSSEXT} optimizeCss="standard"
 done
 
+for i in ${JSDIR}/*${MINEXT}; do
+	gzip -v -c ${i} > ${i}${GZEXT}
+	touch ${i} ${i}${GZEXT}
+done
+
+for i in ${JSDIR}/ext/jquery-*${MINEXT}; do
+	gzip -v -c ${i} > ${i}${GZEXT}
+	touch ${i} ${i}${GZEXT}
+done
+
+gzip -v -c ${JSDIR}/ext/require.js > ${JSDIR}/ext/require.js${GZEXT}
+touch ${JSDIR}/ext/require.js ${JSDIR}/ext/require.js${GZEXT}
+
+for i in ${CSSDIR}/*${MINCSSEXT}; do
+	gzip -v -c ${i} > ${i}${GZEXT}
+	touch ${i} ${i}${GZEXT}
+done
+
+gzip -v -c ${CSSDIR}/ext/jquery.qtip.min.css > ${CSSDIR}/ext/jquery.qtip.min.css${GZEXT}
+touch ${CSSDIR}/ext/jquery.qtip.min.css ${CSSDIR}/ext/jquery.qtip.min.css${GZEXT}
+

comments