From 7ec8739cdd2cb591bdba3ccd0bcf6a048de38558 Mon Sep 17 00:00:00 2001 From: Jeroen Domburg Date: Fri, 10 Apr 2015 18:03:27 +0200 Subject: [PATCH] martonmiklos: Add YUI compression for static css/js files --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index bc57738..d9af05b 100644 --- a/Makefile +++ b/Makefile @@ -80,7 +80,11 @@ CC := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc AR := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-ar LD := $(XTENSA_TOOLS_ROOT)xtensa-lx106-elf-gcc - +# If COMPRESS_W_YUI is set to "yes" then the static css and js files will be compressed with yui-compressor +# http://yui.github.io/yuicompressor/ +#Disabled by default. +#COMPRESS_W_YUI = "yes" +YUI-COMPRESSOR ?= /usr/bin/yui-compressor #### #### no user configurable options below here @@ -165,6 +169,12 @@ webpages.espfs: html/ html/wifi/ mkespfsimage/mkespfsimage ifeq ($(GZIP_COMPRESSION),"yes") $(Q) rm -rf html_compressed; $(Q) cp -r html html_compressed; +ifeq ($(COMPRESS_W_YUI),"yes") + $(Q) echo "Compression assets with yui-compressor. This may take a while..." + $(Q) for file in `find html_compressed -type f -name "*.js"`; do $(YUI-COMPRESSOR) --type js $$file -o $$file; done + $(Q) for file in `find html_compressed -type f -name "*.css"`; do $(YUI-COMPRESSOR) --type css $$file -o $$file; done + $(Q) awk "BEGIN {printf \"YUI compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s html/ | sed 's/\([0-9]*\).*/\1/'`)*100}" +endif $(Q) cd html_compressed; find . -type f -regex ".*/.*\.\(html\|css\|js\)" -exec sh -c "gzip -n {}; mv {}.gz {}" \;; cd ..; $(Q) cd html_compressed; find | ../mkespfsimage/mkespfsimage > ../webpages.espfs; cd ..; $(Q) awk "BEGIN {printf \"GZIP compression ratio was: %.2f%%\\n\", (`du -b -s html_compressed/ | sed 's/\([0-9]*\).*/\1/'`/`du -b -s html/ | sed 's/\([0-9]*\).*/\1/'`)*100}"