-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support to Google Closure to better javascript minification.
- Loading branch information
Arthur Furlan
committed
Oct 10, 2012
1 parent
572eccf
commit 9f1fc20
Showing
1 changed file
with
21 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
@@ -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 | ||
|
@@ -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" | ||
|