DO_NOT_DEPLOY=Makefile deps *.jsx .babelrc .gitignore README
DO_NOT_DELETE=flempires
-DEPS=deps/react.development.js \
-deps/react-dom.development.js \
-deps/react.production.min.js \
-deps/react-dom.production.min.js
+REACT_DEPS=react.js react-dom.js
+REACT_DOWNLOADS=\
+ deps/react.development.js \
+ deps/react-dom.development.js \
+ deps/react.production.min.js \
+ deps/react-dom.production.min.js
-checksums:
- sha512sum --strict -c checksums.sha512
+JSX_SOURCE=$(wildcard */*.jsx)
+JS_TARGETS=$(JSX_SOURCE:.jsx=.js)
+
+all: $(JS_TARGETS) $(REACT_DEPS)
+
+# Execute either of the following to build things:
+#
+# For a development build:
+#
+# make
+#
+# For a production build:
+#
+# make LMNO_BUILD=production
+#
+# Note: To switch between these two, either issue a "make clean"
+# or otherwise start in a clean source tree (such as a
+# after a fresh "git clone" or use "git clean -f -x -d).
+#
+ifeq ($(LMNO_BUILD),production)
+react.js: deps/react.production.min.js
+ cp $^ $@
+
+react-dom.js: deps/react-dom.production.min.js
+ cp $^ $@
-deps: $(DEPS) checksums
+%.js: %.jsx
+ BABEL_ENV=production babeljs $^ --out-file $@
+else
+react.js: deps/react.development.js
+ cp $^ $@
-dev: deps
- cp deps/react.development.js react.js
- cp deps/react-dom.development.js react-dom.js
+react-dom.js: deps/react-dom.development.js
+ cp $^ $@
-prod: deps
- cp deps/react.production.min.js react.js
- cp deps/react-dom.production.min.js react-dom.js
+%.js: %.jsx
+ BABEL_ENV=development babeljs $^ --out-file $@
+endif
+
+checksums: $(REACT_DOWNLOADS)
+ sha512sum --strict -c checksums.sha512
deps/react.development.js:
wget -nv -nc -P deps https://unpkg.com/react@16/umd/react.development.js
deploy:
rm -rf .deploy-source
git clone . .deploy-source
- make -C .deploy-source prod
+ make -C .deploy-source LMNO_BUILD=production
rm -rf .deploy-source/.git
(cd .deploy-source; rsync -avz \
$(DO_NOT_DEPLOY:%=--exclude=%) \
--delete-after \
./ $(DEPLOY_HOST):$(DEPLOY_DIR) )
rm -rf .deploy-source
+
+clean:
+ rm -f $(JS_TARGETS)
+ rm -f $(REACT_DEPS)
+ rm -f $(REACT_DOWNLOADS)
The following Makefile targets will be useful while developing this
code:
- make deps: Download 3rd-party resources to be served by lmno.games
+ make: Download and build JavaScript resources in development mode
- make dev: Configure development versions of "make deps" resources
+ make LMNO_BUILD=production: As above but in production mode
- make prod: Configure production versions of "make deps" resources
+ make deploy: Deploy latest, committed, production-mode content to lmno.games
- make deploy: Deploy latest, committed static content to lmno.games
+Dependencies
+------------
+Compiling the source requires the babel (version 6) CLI to be
+available as "babeljs" along with the "react" preset. This can be
+achieved on Debian with:
+
+ sudo apt install node-babel-cli node-babel-preset-react