-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
81 lines (77 loc) · 3.35 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
# Please install the following components before you RUN this makefile:
# $sudo npm install -g less uglify-js jshint recess
VERSION = v100
ENVIRONMENT = production
APP_DIR = ./application
LIB_DIR = ./assets/lib
DECK_EXT_DIR = ${LIB_DIR}/extensions
JS_DIR = ./assets/scripts
CSS_DIR = ./assets/styles
TOOLS_DIR = ./build/tools
FILE_TPL_DIR = ./build/templates
DATE=$(shell date +%I:%M%p)
CHECK=✔
HR=\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
#
# 压缩合并 JS 文件
#
js:
@echo "\n${HR}"
@echo "\033[32mCompressing Javascript files...\033[39m"
@echo "${HR}\n"
@rm -f ${JS_DIR}/*.min.v*.js
@echo "Removing legacy javascript... ${CHECK} Done"
@uglifyjs -nc ${LIB_DIR}/jquery.js > ${JS_DIR}/jquery.min.${VERSION}.js
@echo "Minifying jquery.js... ${CHECK} Done"
@uglifyjs -nc ${LIB_DIR}/modernizr.custom.js > ${JS_DIR}/modernizr.custom.min.${VERSION}.js
@echo "Minifying modernizr.custom.js... ${CHECK} Done"
@cat ${LIB_DIR}/core/deck.core.js ${DECK_EXT_DIR}/hash/deck.hash.js ${DECK_EXT_DIR}/menu/deck.menu.js \
${DECK_EXT_DIR}/goto/deck.goto.js ${DECK_EXT_DIR}/status/deck.status.js \
${DECK_EXT_DIR}/navigation/deck.navigation.js ${DECK_EXT_DIR}/scale/deck.scale.js > ${JS_DIR}/italk.tmp.js
@uglifyjs -nc ${JS_DIR}/italk.tmp.js > ${JS_DIR}/italk.min.${VERSION}.js
@rm ${JS_DIR}/italk.tmp.js
@echo "Resolving dependencies and minifying the core... ${CHECK} Done"
@echo "\n${HR}"
@echo "\033[32mJavascript files successfully concatenated and minified at ${DATE}.\033[39m"
@echo "${HR}\n"
#
# 压缩合并 CSS (需要 Java 环境支持)
#
css:
@echo "\n${HR}"
@echo "\033[32mCompressing CSS files...\033[39m"
@echo "${HR}\n"
@rm -f ${CSS_DIR}/*.min.v*.css
@echo "Removing legacy CSS files... ${CHECK} Done"
@cat ${LIB_DIR}/font-awesome.css ${LIB_DIR}/core/deck.core.css ${DECK_EXT_DIR}/goto/deck.goto.css \
${DECK_EXT_DIR}/menu/deck.menu.css ${DECK_EXT_DIR}/navigation/deck.navigation.css \
${DECK_EXT_DIR}/status/deck.status.css ${DECK_EXT_DIR}/goto/deck.goto.css \
${DECK_EXT_DIR}/hash/deck.hash.css ${DECK_EXT_DIR}/scale/deck.scale.css \
${LIB_DIR}/themes/style/web-2.0.css ${LIB_DIR}/themes/transition/horizontal-slide.css \
${LIB_DIR}/italk.css > ${CSS_DIR}/italk.tmp.css
@java -jar ${TOOLS_DIR}/yuicompressor-2.4.7.jar --charset utf-8 ${CSS_DIR}/italk.tmp.css -o ${CSS_DIR}/italk.min.${VERSION}.css
@rm ${CSS_DIR}/italk.tmp.css
@echo "Resolving dependencies and minifying the core css... ${CHECK} Done"
@echo "\n${HR}"
@echo "\033[32mCSS files successfully concatenated and minified at ${DATE}.\033[39m"
@echo "${HR}\n"
#
# 更新 assets.config 文件中的版本号
#
version:
@echo "\n${HR}"
@echo "\033[32mBumping version...\033[39m"
@echo "${HR}\n"
@sed -e s/'@VERSION@'/'${VERSION}'/g ${FILE_TPL_DIR}/assets.php > ${APP_DIR}/config/assets.php
@echo "Bumping assets to version ${VERSION}... ${CHECK} Done"
@sed -e s/'@ENVIRONMENT@'/'${ENVIRONMENT}'/g ${FILE_TPL_DIR}/index.php > ./index.php
@echo "Set environment to *${ENVIRONMENT}* for the application... ${CHECK} Done"
@echo "\n${HR}"
@echo "\033[32mSet current version to ${VERSION} at ${DATE}.\033[39m"
@echo "${HR}\n"
deploy:
make version
make js
make css
# 自定义:调用执行其他脚本,如重置系统缓存、重启服务器、发送邮件通知管理员等
#make more