Skip to content

Commit

Permalink
Update the Makefile to support dependency checking for JS and LESS
Browse files Browse the repository at this point in the history
We can now build less files that are separate from the main css.
  • Loading branch information
kabel committed Jul 2, 2013
1 parent 9679b31 commit 3023789
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,30 +1,49 @@
export PATH := $(PATH):build/bin
TEMPLATE_DIR := wdn/templates_4.0
TEMPLATE_LESS := $(TEMPLATE_DIR)/less
TEMPLATE_CSS := $(TEMPLATE_DIR)/css
TEMPLATE_JS := $(TEMPLATE_DIR)/scripts
TEMPLATE_RJS := $(TEMPLATE_JS)/compressed

GIT := git

LESSC := lessc
LESSC_FLAGS := --yui-compress --line-numbers=comments
LESS_OBJS := all.less
LESS_OUT ?= $(LESS_OBJS:.less=.css)

LESS_MIXINS := $(TEMPLATE_LESS)_mixins/all.less
LESS_MIXINS_DEPS := $(filter %.less, $(shell $(LESSC) -M $(LESS_MIXINS) .tmp))
LESS_ALL := all.less
LESS_ALL_OUT := all.css
CSS_OBJS := \
$(TEMPLATE_CSS)/$(LESS_ALL_OUT) \
$(TEMPLATE_CSS)/layouts/unlalert.css

RJS := r.js
RJS_FLAGS :=
JS_BUILD_CONF := build/build.js
RJS_BUILD_CONF := build/build.js
JS_ALL_OUT := $(TEMPLATE_RJS)/all.js
JS_DEPS := $(TEMPLATE_JS)/*.js

SMUDGE_STATUS := $(shell $(GIT) config filter.rcs-keywords.smudge)

all: less js

less:
$(LESSC) $(LESSC_FLAGS) $(TEMPLATE_DIR)/less/$(LESS_OBJS) $(TEMPLATE_DIR)/css/$(LESS_OUT)
less: $(CSS_OBJS)

$(shell $(LESSC) -M $(TEMPLATE_LESS)/$(LESS_ALL) $(TEMPLATE_CSS)/$(LESS_ALL_OUT))

$(TEMPLATE_CSS)/%.css: $(TEMPLATE_LESS)/%.less $(LESS_MIXINS_DEPS)
@mkdir -p $(@D)
$(LESSC) $(LESSC_FLAGS) $< $@

js: $(JS_ALL_OUT)

js:
$(RJS) -o $(JS_BUILD_CONF) $(RJS_FLAGS)
$(JS_ALL_OUT): $(RJS_BUILD_CONF) $(JS_DEPS)
$(RJS) -o $(RJS_BUILD_CONF) $(RJS_FLAGS)

clean:
rm -rf $(TEMPLATE_DIR)/css
rm -rf $(TEMPLATE_DIR)/scripts/compressed
rm -rf $(TEMPLATE_CSS)
rm -rf $(TEMPLATE_RJS)

dist: all
@if test -z "$(SMUDGE_STATUS)"; then \
Expand Down

0 comments on commit 3023789

Please sign in to comment.