Created
August 31, 2012 06:07
-
-
Save jdp/3549544 to your computer and use it in GitHub Desktop.
Use Makefiles for CoffeeScript, Handlebars, and Sass
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
COFFEEC = coffee | |
SASSC = sass | |
HANDLEBARSC = handlebars | |
# Build app package | |
APPSRC = static/scripts/main.coffee | |
APPOBJ = ${APPSRC:.coffee=.js} | |
APPOUT = static/scripts/app.js | |
$(APPOUT): $(APPOBJ) | |
cat $^ > $@ | |
%.js: %.coffee | |
$(COFFEEC) -bc $< | |
.PHONY: scripts | |
scripts: $(APPOUT) | |
# Build vendor package | |
VENDORSRC = static/scripts/vendor/zepto.js \ | |
static/scripts/vendor/underscore.js \ | |
static/scripts/vendor/backbone.js \ | |
static/scripts/vendor/handlebars-1.0.0.beta.6.js | |
VENDOROUT = static/scripts/vendor.js | |
$(VENDOROUT): $(VENDORSRC) | |
cat $^ > $@ | |
.PHONY: vendor | |
vendor: $(VENDOROUT) | |
# Build templates javascript | |
TEMPLATESRC = static/templates/form.handlebars \ | |
static/templates/profile.handlebars \ | |
static/templates/timeline.handlebars \ | |
static/templates/tweet.handlebars | |
TEMPLATEOBJ = ${TEMPLATESRC:.handlebars=.js} | |
TEMPLATEOUT = static/scripts/templates.js | |
$(TEMPLATEOUT): $(TEMPLATEOBJ) | |
cat $^ > $@ | |
%.js: %.handlebars | |
$(HANDLEBARSC) $< -f $@ | |
.PHONY: templates | |
templates: $(TEMPLATEOUT) | |
# Build stylesheets | |
STYLESRC = static/styles/main.sass \ | |
static/styles/mixins.sass | |
STYLEOBJ = ${STYLESRC:.sass=.css} | |
STYLEOUT = static/styles/app.css | |
$(STYLEOUT): $(STYLEOBJ) | |
cp $< $@ | |
%.css: %.sass | |
$(SASSC) -C $< > $@ | |
.PHONY: styles | |
styles: $(STYLEOUT) | |
.PHONY: all | |
all: scripts vendor templates styles | |
.PHONY: clean | |
clean: | |
-rm $(APPOBJ) | |
-rm $(APPOUT) | |
-rm $(VENDOROUT) | |
-rm $(TEMPLATEOBJ) | |
-rm $(TEMPLATEOUT) | |
-rm $(STYLEOBJ) | |
-rm $(STYLEOUT) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment