-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
59 lines (44 loc) · 1.38 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
BABEL = node_modules/.bin/babel
WEBPACK = node_modules/.bin/webpack
LINT = node_modules/.bin/eslint
JEST = node_modules/.bin/jest
# node targetted babel: ignore .babelrc which targets webpack/browser
BABEL_ARGS = --no-babelrc --source-maps --presets=react,stage-2 \
--plugins=babel-plugin-transform-es2015-modules-commonjs
WEBPACK_PROD_ARGS = --config webpack/production.js -p
WEBPACK_DEV_ARGS = --config webpack/development.js
SRC = $(shell find src -name "*.js" -type f)
LIB = $(SRC:src/%.js=lib/%.js)
all : build
build : $(LIB) public/.dirstamp public/favicon.ico
start :
node ./lib/server/server.js
start-dev : public/favicon.ico
node ./src/server/dev-server.js
start-debug :
DEBUG=express:* node --inspect ./src/server/dev-server.js
test:
$(JEST)
# node/server libs
$(LIB) : lib/%.js: src/%.js
mkdir -p $(@D)
$(LINT) $<
$(BABEL) $< --out-file $@ $(BABEL_ARGS)
# bundle for browser
public/.dirstamp: $(filter src/client/%.js,$(SRC))
mkdir -p ./public && touch $@
ifeq ($(strip $(NODE_ENV)), production)
@echo "Webpack building with production config"
$(WEBPACK) $(WEBPACK_PROD_ARGS)
else
@echo "\033[41mWebpack building with development config\033[0m"
$(WEBPACK) $(WEBPACK_DEV_ARGS)
endif
public/favicon.ico: assets/favicon.ico
mkdir -p ./public
cp $< $@
clean :
rm -rf lib public webpack_cache
clean-deps :
rm -rf node_modules
.PHONY: build clean clean-deps start start-dev