forked from appleboy/backbone-template-engine
/
Makefile
81 lines (67 loc) · 2.58 KB
/
Makefile
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
.PHONY: output init template css build test compass coffee livereload server
# setup path
app_path ?= $(shell echo "app")
output_path ?= $(shell echo "output")
# Using time as file name
filetime:=$(shell date '+%Y%m%d%H%M%S')
file_list:=$(find assets/templates/ -name "*.handlebars")
all: init
r.js -o build/self.build.js
compass:
$@ watch .
coffee:
$@ -b -w -c -o $(app_path)/assets/js $(app_path)/assets/coffeescript
livereload:
guard start
server:
node build/server.js
init:
@which bower 1> /dev/null 2>&1 ; if [ $$? -ne 0 ] ; then ./build/build.sh ; fi
@test -d "$(app_path)/assets/vendor" || bower install
@echo "Install bower package compeletely."
@npm install
template:
-mkdir "$(app_path)/assets/tmp"
for file in `find $(app_path)/assets/templates/ -type f -name '*.handlebars'`; \
do \
name=`basename $$file`; \
java -jar build/htmlcompressor-1.5.3.jar --remove-intertag-spaces --compress-js -o $(app_path)/assets/tmp/$$name $$file; \
done
handlebars $(app_path)/assets/tmp/*.handlebars -m -f $(app_path)/assets/templates/template.js -k each -k if -k unless
rm -rf "$(app_path)/assets/tmp"
css:
for file in `find $(output_path)/assets/css/ -type f -name '*.css'`; \
do \
sqwish $$file -o $$file; \
done
build: all
rm -rf $(output_path)
r.js -o build/app.build.js dir=$(output_path)
release: template build css
rm -rf $(output_path)/assets/js/*
cp -r $(output_path)/assets/vendor/requirejs/require.js $(output_path)/assets/js/
cp -r $(app_path)/assets/js/main-built.js $(output_path)/assets/js/$(filetime).js
cp -r $(app_path)/.htaccess $(output_path)/
rm -rf $(output_path)/build.txt
rm -rf $(output_path)/assets/coffeescript $(output_path)/assets/sass
rm -rf $(output_path)/assets/vendor $(output_path)/assets/templates
sed -i 's/js\/main/js\/$(filetime)/g' $(output_path)/index.html
sed -i 's/vendor\/requirejs\//js\//g' $(output_path)/index.html
-java -jar build/htmlcompressor-1.5.3.jar --remove-intertag-spaces --compress-js -o $(output_path)/index.html $(output_path)/index.html
@echo
@echo "======================================================="
@echo "=> Install compeletely."
@echo "=> Please copy output folder to your web root path."
@echo "======================================================="
@echo
clean:
rm -rf output
rm -rf node_modules
rm -rf $(app_path)/assets/vendor
rm -rf $(app_path)/assets/tmp
rm -rf $(app_path)/assets/templates/template.js
rm -rf $(app_path)/assets/js/main-built.js
rm -rf $(app_path)/assets/js/main-built.js.map
rm -rf $(app_path)/assets/js/main-built.js.src
test: release
@./node_modules/.bin/mocha --reporter spec