-
Notifications
You must be signed in to change notification settings - Fork 1
/
js.build.babel.mk
47 lines (33 loc) · 1.24 KB
/
js.build.babel.mk
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
BABEL = $(call npm-which,BABEL,babel)
BABEL_NODE = $(call npm-which,BABEL_NODE,babel-node)
$(foreach VAR,BABEL BABEL_NODE,$(call make-lazy,$(VAR)))
BABELRC := $(shell $(FIND_Q_NOSYM) . -mindepth 0 -maxdepth 1 -name ".babelrc*" -print)
LIB_JS_FROM_JS_FILES += \
$(patsubst src/%.js,lib/%.js,$(SRC_JS_FILES)) \
LIB_JS_FROM_TS_FILES += \
$(patsubst src/%.ts,lib/%.js,$(SRC_TS_FILES)) \
LIB_JS_FILES += \
$(LIB_JS_FROM_JS_FILES) \
$(LIB_JS_FROM_TS_FILES) \
LIB_JS_MAP_FILES += \
$(patsubst src/%.js,lib/%.js.map,$(SRC_JS_FILES)) \
$(patsubst src/%.ts,lib/%.js.map,$(SRC_TS_FILES)) \
SF_CLEAN_FILES += \
$(LIB_JS_FILES) \
$(LIB_JS_MAP_FILES) \
SF_BUILD_TARGETS += \
build-babel \
BABEL_ARGS += \
--source-maps
# ------------------------------------------------------------------------------
$(LIB_JS_FROM_JS_FILES): lib/%.js: src/%.js $(SRC_JS_FILES) $(BABELRC)
$(MKDIR) $(shell dirname $@)
$(BABEL) $< $(BABEL_ARGS) --out-file $@
$(LIB_JS_FROM_TS_FILES): lib/%.js: src/%.ts $(SRC_JS_FILES) $(BABELRC)
$(MKDIR) $(shell dirname $@)
$(BABEL) $< $(BABEL_ARGS) --out-file $@
.PHONY: build-babel
build-babel:
[[ "$(words $(LIB_JS_FROM_JS_FILES) $(LIB_JS_FROM_TS_FILES))" = "0" ]] || { \
$(MAKE) $(LIB_JS_FROM_JS_FILES) $(LIB_JS_FROM_TS_FILES); \
}