-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (49 loc) · 1.54 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
# Overridable Config
SRC_DIR ?= src
DST_DIR ?= public
NODE_MODULES ?= node_modules
ifeq ($(VERBOSE),1)
MUTE :=
else
MUTE := @
endif
# Reference to node binaries without installing globally
watch := $(NODE_MODULES)/.bin/watchthis
tsc := $(NODE_MODULES)/.bin/tsc
nodesass := $(NODE_MODULES)/.bin/node-sass
# Typescript source files & js transpiled files
SRC_TS_FILES != find $(SRC_DIR)/ts -name '*.ts'
DST_JS_FILES := $(SRC_TS_FILES:$(SRC_DIR)/ts/%.ts=$(DST_DIR)/js/%.js)
# Sass source files & css transpiled files
SRC_SASS_FILES != find $(SRC_DIR)/scss/ -regex '[^_]*.scss'
DST_CSS_FILES := $(SRC_SASS_FILES:$(SRC_DIR)/scss/%.scss=$(DST_DIR)/css/%.css)
# HTML files & injected HTML
SRC_HTML_FILES != find $(SRC_DIR) -name '*.html'
DST_HTML_FILES := $(SRC_HTML_FILES:$(SRC_DIR)/%=$(DST_DIR)/%)
# Dependency checks
YARN != command -v yarn 2> /dev/null
# Macros
copy = cp $< $@
mkdir = $(MUTE)mkdir -p $(dir $@)
.PHONY: all clean watch install
all: node_modules $(DST_JS_FILES) $(DST_CSS_FILES) $(DST_HTML_FILES)
clean:
rm -rf $(DST_DIR)
watch:
$(shell $(watch) -a ./$(SRC_DIR) make)
$(DST_DIR)/js/%.js: $(SRC_DIR)/ts/%.ts
$(mkdir)
$(tsc) $< --outFile $@
$(DST_DIR)/css/%.css: $(SRC_DIR)/scss/%.scss
$(mkdir)
$(nodesass) --output-style compressed $< $@
$(DST_DIR)/%.html: $(SRC_DIR)/%.html
$(mkdir)
cp $< $@
install:
ifndef YARN
$(error Missing dependency 'yarn'. Please install and try again.)
endif
node_modules: package.json yarn.lock
yarn install --modules-folder ./$(NODE_MODULES)
touch $(NODE_MODULES) # fixes watch bug if you manually ran yarn