-
Notifications
You must be signed in to change notification settings - Fork 21
/
Makefile
106 lines (77 loc) · 2.91 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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/bash
## Copyright (c) 2015 - Andreas Dewes
##
## This file is part of Gitboard.
##
## Gitboard is free software: you can redistribute it and/or modify
## it under the terms of the GNU Affero General Public License as
## published by the Free Software Foundation, either version 3 of the
## License, or (at your option) any later version.
##
## This program is distributed in the hope that it will be useful,
## but WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
## GNU Affero General Public License for more details.
##
## You should have received a copy of the GNU Affero General Public License
## along with this program. If not, see <http://www.gnu.org/licenses/>.
BUILD_DIR=build
SOURCE_DIR=src
CSS_FILES = /css/main.css
export PATH := ./node_modules/.bin:$(PATH);
ifeq ($(ENVIRONMENT),production)
BUILD_ENVIRONMENT=production
else
BUILD_ENVIRONMENT=development
endif
ifeq ($(NAVIGATION),html5)
ENV_SETTINGS=settings_html5_navigation.js
else
ENV_SETTINGS=settings_hashtag_navigation.js
endif
all: $(BUILD_ENVIRONMENT)
clean:
rm -rf $(BUILD_DIR)
chrome-development: npm bower assets scripts jsx templates env_settings scss chrome watch
chrome-production: npm bower assets scripts jsx templates env_settings scss chrome optimize
chrome-app-development: npm bower assets scripts jsx templates env_settings scss chrome-app watch
chrome-app-production: npm bower assets scripts jsx templates env_settings scss chrome-app optimize
production: npm bower assets scripts jsx templates env_settings scss optimize
development: npm bower assets scripts jsx templates env_settings scss watch
optimize: optimize-css optimize-rjs
npm:
npm install
scss: $(SOURCE_DIR)/scss/main.scss
mkdir -p $(BUILD_DIR)/static/css
scss $(SOURCE_DIR)/scss/main.scss $(BUILD_DIR)/static/css/main.css
chrome:
cp $(SOURCE_DIR)/chrome/* $(BUILD_DIR) -rf
chrome-app:
cp $(SOURCE_DIR)/chrome-app/* $(BUILD_DIR) -rf
env_settings:
cp $(SOURCE_DIR)/js/$(ENV_SETTINGS) $(BUILD_DIR)/static/js/env_settings.js
optimize-css:
mkdir -p $(BUILD_DIR)/static/css
cleancss -o $(BUILD_DIR)/static/css/main.css $(addprefix $(BUILD_DIR)/static,$(CSS_FILES))
optimize-rjs:
r.js -o $(BUILD_DIR)/static/js/build.js
scripts:
mkdir -p $(BUILD_DIR)/static/js
rsync -rupE $(SOURCE_DIR)/js --include="*.js" $(BUILD_DIR)/static
templates:
mkdir -p $(BUILD_DIR)
rsync -rupE $(SOURCE_DIR)/templates/ --include="*.html" $(BUILD_DIR)
jsx:
jsx $(SOURCE_DIR)/js $(BUILD_DIR)/static/js -x jsx
assets:
rsync -rupE $(SOURCE_DIR)/assets $(BUILD_DIR)/static
.PHONY: scripts
bower:
mkdir -p $(BUILD_DIR)/static
bower install --config.directory=$(BUILD_DIR)/static/bower_components
watch:
@which inotifywait || (echo "Please install inotifywait";exit 2)
@while true ; do \
inotifywait -r src -e create,delete,move,modify || break; \
($(MAKE) assets scripts jsx templates chrome chrome-app scss) || break;\
done