My favorites | Sign in
Project Home Downloads Wiki Issues Source
Checkout   Browse   Changes    
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60

CSS_SOURCES = \
static/css/first.css \
static/css/second.css \
static/css/third.css \
static/css/and_so_on.css

JS_SOURCES = \
static/js/first.js \
static/js/second.js \
static/js/third.js \
static/js/and_so_on.js

JS_MINIFIED_DEPS = \
jquery-ui-1.8.2.custom/js/jquery-1.4.2.min.js \
jquery-ui-1.8.2.custom/js/jquery-ui-1.8.2.custom.min.js \
jquery-ui-1.8.2.custom/js/jquery.ui.datepicker-pt-BR.min.js

CSS_MINIFIED = $(addsuffix .min.css, $(basename ${CSS_SOURCES}))
JS_MINIFIED = $(addsuffix .min.js, $(basename ${JS_SOURCES}))
CSS_TARGET = static/css/all.css
JS_TARGET = static/js/all.js

.PHONY: all clean minify_css concat_css minify_js concat_js

all: minify_css concat_css minify_js concat_js
@echo Done.

minify_css: $(CSS_MINIFIED)
minify_js: $(JS_MINIFIED)
concat_css: $(CSS_TARGET)
concat_js: $(JS_TARGET)

%.min.css: %.css
@echo [css] $<
@java -jar lib/yuicompressor-2.4.2.jar $< -o $@

%.min.js: %.js
@echo [js] $<
@java -jar lib/yuicompressor-2.4.2.jar $< -o $@

$(CSS_TARGET): $(CSS_MINIFIED)
# @> $@ # truncate
# @for file in $(CSS_MINIFIED); do cat $${file} >> $@; done
@cat $(CSS_MINIFIED) > $@
@echo "[tag] @import url(\"$@\");"

$(JS_TARGET): $(JS_MINIFIED)
# @> $@ # truncate
# @for file in $(JS_MINIFIED_DEPS); do cat $${file} >> $@; done
# @for file in $(JS_MINIFIED); do cat $${file} >> $@; done
@cat $(JS_MINIFIED_DEPS) > $@
@cat $(JS_MINIFIED) >> $@
@echo "[tag] <script type=\"text/javascript\" src=\"$@\"></script>"

clean:
-@rm -f \
$(CSS_MINIFIED) $(CSS_TARGET) \
$(JS_MINIFIED) $(JS_TARGET)
@echo Cleaned.

Change log

r31 by jweyrich on Aug 2, 2010   Diff
Make concat targets depend on minified
files, so it updates when a file is
changed.
Go to: 
Project members, sign in to write a code review

Older revisions

r30 by jweyrich on Jul 31, 2010   Diff
Oops! Use > instead of >>.
r29 by jweyrich on Jul 31, 2010   Diff
Pass the file list to cat instead of
doing a loop.
r28 by jweyrich on Jul 31, 2010   Diff
Adding Makefile for JavaScript and CSS
minification+concatenation.
All revisions of this file

File info

Size: 1565 bytes, 60 lines

File properties

svn:eol-style
LF
Powered by Google Project Hosting