-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.mk
43 lines (34 loc) · 1.57 KB
/
index.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
$(register-npm-bin)
$(call require, fait-macro)
# Directory to look for source Javascript files (determined by `$(babel-extensions)`).
babel-src-dir = src
# Directory to put compiled Javascript files.
babel-dst-dir = lib
# Extensions that we consider "Javascript source files". `.js` and `.jsx` by default.
babel-extensions = .js .jsx
~babel-extension-find-args = $(patsubst %, -name '*%' -o, $(babel-extensions)) -false
~babel-src-files = $(shell find $(babel-src-dir) $(~babel-extension-find-args) 2>/dev/null)
~babel-dst-files = $(patsubst $(babel-src-dir)/%, $(babel-dst-dir)/%, $(~babel-src-files))
# Options to pass to Babel.
babel-opts =
# Default entry target.
babel: $(~babel-dst-files)
-include $(~module-dir)babel.mk
# Install Babel plugins and write to `.babelrc`. Configured by the variables
# `$(plugins)` and `$(presets)`, which you should pass on the command line.
#
# If you want to e.g. install `babel-preset-es2015` and
# `babel-plugin-transform-runtime`, the command would be
# `make babel-install-plugins presets+=es2015 plugins+=transform-runtime`.
#
# If you install `transform-runtime`, `babel-runtime` is also installed.
#
# Uses [`@quarterto/bae`](https://github.com/quarterto/bae) under the hood.
babel-install-plugins:
bae $(patsubst %, -p %, $(plugins)) $(patsubst %, -s %, $(presets))
# Same as `babel-install-plugins` but uninstalls and removes things from `.babelrc`
# instead.
babel-remove-plugins:
bae -r $(patsubst %, -p %, $(plugins)) $(patsubst %, -s %, $(presets))
.PHONY: babel-install-plugins babel-remove-plugins
fait-babel-version := $(module-version)