Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2019-11-25 14:04:02 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2019-11-25 16:18:39 +0300
commit54bdb870e6fd71abf1f9b2b848549b928bd47f6c (patch)
treefc0ae3f8e44a07a2bad60b1a25cc8edea266afb1 /scripts
parent9da9b9e1f684724b96e6694c34c87457de8a8989 (diff)
Minify assets (HTML,CSS,JS,JSON,XML,SVG)
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/minify-assets.sh26
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"