Skip to content

Instantly share code, notes, and snippets.

@MindTwister
Created February 6, 2013 10:46
Show Gist options
  • Save MindTwister/4721841 to your computer and use it in GitHub Desktop.
Save MindTwister/4721841 to your computer and use it in GitHub Desktop.
Coffee script redux makefile with source maps
# Coffee source (must be publicly available)
COFFEE_FOLDER = public/src/coffee/
JS_FOLDER = public/js/
COFFEE = $(shell find $(COFFEE_FOLDER) -type f -name '*.coffee')
JS = $(patsubst $(COFFEE_FOLDER)%.coffee, $(JS_FOLDER)%.js, $(COFFEE))
JS_MAP = $(patsubst $(COFFEE_FOLDER)%.coffee, $(JS_FOLDER)%.js.map, $(COFFEE))
.PHONY: all clean
all: $(JS) $(JS_MAP)
$(JS_FOLDER)%.js: $(COFFEE_FOLDER)%.coffee
@mkdir -p "$(@D)"
@echo Compiling "$($@)"
coffee --js < $< > $@
echo "//@ sourceMappingURL=$(@F).map" >> $@
$(JS_FOLDER)%.js.map: $(COFFEE_FOLDER)%.coffee
@mkdir -p "$(@D)"
@echo Compiling "$($@)"
coffee --source-map -i $< | sed 's#public#..#g' > $@
clean:
rm -rf $(JS) $(JS_MAP)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment