Skip to content

Instantly share code, notes, and snippets.

@bpierre
Created November 5, 2011 17:34
Show Gist options
  • Save bpierre/1341808 to your computer and use it in GitHub Desktop.
Save bpierre/1341808 to your computer and use it in GitHub Desktop.
A Makefile to concatenate / minify my JS Scripts and convert/compress my Stylus (CSS preprocessor) files
# JS files
JS_FINAL = js/project-name-all.js
JS_TARGETS = js/file1.js \
js/file2.js \
js/file3.js
# CSS files
CSS_FINAL = css/project-name-all.css
STYLUS_TARGETS = css/file1.styl \
css/file2.styl
# Binaries
UGLIFY_BIN = uglifyjs
STYLUS_BIN = stylus
STYLUS_PARAMETERS = -I /usr/local/lib/node_modules/nib/lib/
CSS_MINIFIED = $(STYLUS_TARGETS:.styl=.min.css)
JS_MINIFIED = $(JS_TARGETS:.js=.min.js)
all: $(JS_FINAL) $(CSS_FINAL)
# JS
$(JS_FINAL): $(JS_MINIFIED)
cat $^ >$@
rm -f $^
%.min.js: %.js
$(UGLIFY_BIN) -o $@ $<
echo >> $@
# CSS
$(CSS_FINAL): $(CSS_MINIFIED)
cat $^ >$@
rm -f $(CSS_MINIFIED)
%.min.css: %.styl
$(STYLUS_BIN) --compress $(STYLUS_PARAMETERS) <$< >$@
clean:
rm -f $(JS_FINAL) $(CSS_FINAL)
.DEFAULT_GOAL := all
.PHONY: clean css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment