Skip to content

Commit

Permalink
Add support to Google Closure to better javascript minification.
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur Furlan committed Oct 10, 2012
1 parent 572eccf commit 9f1fc20
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/minify.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#!/bin/bash
#
# written by Arthur Furlan <[email protected]>
# written by Osvaldo Santana <[email protected]>
# by Arthur Furlan <[email protected]>

YUICOMPRESS="yuicompressor-2.4.6.jar"
YUICOMPRESSOR="yuicompressor.jar"
GOOGLECLOSURE="googleclosure.jar"

if [ $# -lt 1 ]; then
echo "Usage: $0 BASEDIR"
Expand Down Expand Up @@ -53,7 +54,7 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do

case "$TYPE" in

css|js)
js)
DEST="${NAME}.min.${TYPE}"

## check if the file needs to be minified
Expand All @@ -62,7 +63,23 @@ find "$BASEDIR" -type f | egrep -v '\.min\.' | while read FILE; do

## create the new (and minified) version
echo "Compressing: ${DEST}"
java -jar "${YUICOMPRESS}" "${FILE}" > "${DEST}"
java -jar "${GOOGLECLOSURE}" --js "${FILE}" --compilation_level SIMPLE_OPTIMIZATIONS > "${DEST}"

## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
[ "$?" = "0" ] || cp "$FILE" "$DEST"
;;

css)
DEST="${NAME}.min.${TYPE}"

## check if the file needs to be minified
is_file_modified "$FILE" "$DEST"
[ "$?" = "1" ] || continue

## create the new (and minified) version
echo "Compressing: ${DEST}"
java -jar "${YUICOMPRESSOR}" "${FILE}" > "${DEST}"

## check if the minified file really is smaller
is_file_minified "$FILE" "$DEST"
Expand Down

0 comments on commit 9f1fc20

Please sign in to comment.