diff options
author | Achilleas Pipinellis <axil@gitlab.com> | 2019-11-25 14:04:02 +0300 |
---|---|---|
committer | Achilleas Pipinellis <axil@gitlab.com> | 2019-11-25 16:18:39 +0300 |
commit | 54bdb870e6fd71abf1f9b2b848549b928bd47f6c (patch) | |
tree | fc0ae3f8e44a07a2bad60b1a25cc8edea266afb1 /scripts | |
parent | 9da9b9e1f684724b96e6694c34c87457de8a8989 (diff) |
Minify assets (HTML,CSS,JS,JSON,XML,SVG)
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/minify-assets.sh | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/scripts/minify-assets.sh b/scripts/minify-assets.sh new file mode 100755 index 00000000..982aa650 --- /dev/null +++ b/scripts/minify-assets.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +TARGET="$1" +VER="$2" + +if [ -z "$TARGET" -o -z "$VER" ]; then + echo "Usage: $0 <target> <ver>" + echo "Either <target> or <ver> is missing. Exiting." + exit 1 +fi + +if ! [ -d "$TARGET" ]; then + echo "Target directory $TARGET does not exist. Exiting." + exit 1 +fi + +# Minify assets +printf "Optimizing assets..." + +printf "HTML..."; /scripts/minify -r --type=html --match=\.html -o ${TARGET}/ ${TARGET} || true +printf "CSS..." ; /scripts/minify -r --type=css --match=\.css -o ${TARGET}/ ${TARGET} || true +printf "JSON..."; /scripts/minify -r --type=json --match=\.json -o ${TARGET}/ ${TARGET} || true +printf "SVG..." ; /scripts/minify -r --type=svg --match=\.svg -o ${TARGET}/ ${TARGET} || true +printf "XML..." ; /scripts/minify -r --type=xml --match=\.xml -o ${TARGET}/ ${TARGET} || true + +echo "Done" |