Skip to content

Instantly share code, notes, and snippets.

@pamelafox
Created April 25, 2011 19:09
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save pamelafox/941017 to your computer and use it in GitHub Desktop.
Save pamelafox/941017 to your computer and use it in GitHub Desktop.
JS/CSS Compressor Makefile
# Javascript/CSS Compressor Makefile
# Original by Benjamin "balupton" Lupton (MIT Licenced)
# Modified by Pamela Fox
MAKEFLAGS = --no-print-directory --always-make
MAKE = make $(MAKEFLAGS)
BUILDDIR = ./.build
CLOSUREURL = http://closure-compiler.googlecode.com/files/compiler-latest.zip
CLOSUREDIR = $(BUILDDIR)/closure
CLOSUREFILE = $(CLOSUREDIR)/compiler.jar
YUIURL = http://yuilibrary.com/downloads/yuicompressor/yuicompressor-2.4.2.zip
YUIDIR = $(BUILDDIR)/yui
YUIFILE = $(YUIDIR)/yuicompressor-2.4.2/build/yuicompressor-2.4.2.jar
jshint:
jshint ./static/js/main.js;
pack:
cat \
./static/js/jquery.calendrical.js \
./static/js/jquery.overlay.js \
./static/js/jquery.smileyslider.js \
./static/js/jquery.timeago.js \
./static/js/raphael.js \
./static/js/main.js \
> ./static/js/all.js;
compress:
java -jar $(CLOSUREFILE) --js_output_file=./static/js/all-min.js --js=./static/js/all.js;
java -jar $(YUIFILE) ./static/css/desktop.css -o ./static/css/desktop-min.css;
sed -i '' "s/all-min\.js\?v=[0-9]*/all-min\.js\?v=`date +%s`/" templates/base.html;
sed -i '' "s/desktop\.css?v=[0-9]*/desktop\.css\?v=`date +%s`/" templates/base.html;
sed -i '' "s/all-min\.js\?v=[0-9]*/all-min\.js\?v=`date +%s`/" templates/talks/mobile.html;
build:
$(MAKE) jshint;
$(MAKE) pack;
$(MAKE) compress;
build-update:
$(MAKE) clean;
mkdir $(BUILDDIR) $(CLOSUREDIR) $(YUIDIR);
cd $(CLOSUREDIR); curl -L $(CLOSUREURL) > file.zip; tar -xf file.zip;
cd $(YUIDIR); curl -L $(YUIURL) > file.zip; tar -xf file.zip;
all:
$(MAKE) build;
clean:
rm -Rf $(BUILDDIR);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment