summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Kylie McClain <somasis@exherbo.org> 2015-08-30 14:43:43 -0400
committerAvatar Kylie McClain <somasis@exherbo.org> 2015-08-30 14:44:08 -0400
commitfcafcac998b2a26dc46beac3643f8739d3da3ebf (patch)
treeb1a86e33cb63546152957b442d001803713cc3c9
parent9f0593b9ba8326754e3327d8adb1c1e50f4aa0e9 (diff)
downloadwww-fcafcac998b2a26dc46beac3643f8739d3da3ebf.tar.gz
www-fcafcac998b2a26dc46beac3643f8739d3da3ebf.tar.xz
Makefile/minify: remove trailing and leading spaces in minified files
Change-Id: I0526bb2b4030abba7bc833437f917c222415c608
-rw-r--r--Makefile13
1 files changed, 10 insertions, 3 deletions
diff --git a/Makefile b/Makefile
index 95d73ed..fb76c8a 100644
--- a/Makefile
+++ b/Makefile
@@ -53,14 +53,21 @@ else
minify:
@if [[ -z "$(FILE)" ]];then echo "FILE=<file to minify>" >&2; exit 1;fi
@echo "Minifying $(FILE) ..."
- @sed -e "s|/\*\(\\\\\)\?\*/|/~\1~/|g" \
+ @sed \
+ -e "s|/\*\(\\\\\)\?\*/|/~\1~/|g" \
-e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" \
-e "s|\([^:/]\)//.*$$|\1|" -e "s|^//.*$$||" \
"$(FILE)" >"$(FILE)".tmp
@cat "$(FILE)".tmp > "$(FILE)"
@tr '\n' ' ' <"$(FILE)" > "$(FILE)".tmp
- @sed -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" -e "s|/\~\(\\\\\)\?\~/|/*\1*/|g" \
- -e "s|\s\+| |g" -e "s| \([{;:,]\)|\1|g" -e "s|\([{;:,]\) |\1|g" -i "$(FILE).tmp"
+ @sed \
+ -e "s|/\*[^*]*\*\+\([^/][^*]*\*\+\)*/||g" \
+ -e "s|/\~\(\\\\\)\?\~/|/*\1*/|g" \
+ -e "s|\s\+| |g" \
+ -e "s| \([{;:,]\)|\1|g" \
+ -e "s|\([{;:,]\) |\1|g" \
+ -e "s/^ *//;s/ *$$//" \
+ -i "$(FILE).tmp"
@cat "$(FILE)".tmp > "$(FILE)"
@rm "$(FILE)".tmp