2018-10-05 09:37:48 +00:00
|
|
|
DIST_DIR := www
|
|
|
|
|
2018-09-28 19:20:15 +00:00
|
|
|
SCRIPT_SRC := $(wildcard src/scripts/*.js)
|
|
|
|
|
2018-10-05 09:37:48 +00:00
|
|
|
SCRIPT_DEST := $(SCRIPT_SRC:src/%=$(DIST_DIR)/%)
|
2018-09-28 19:20:15 +00:00
|
|
|
|
|
|
|
default: build
|
|
|
|
|
|
|
|
clean:
|
2018-10-17 21:04:03 +00:00
|
|
|
git clean -fXd -e !src/config.pug
|
2018-09-28 19:20:15 +00:00
|
|
|
|
2018-10-05 11:07:14 +00:00
|
|
|
install: node_modules copy_lib copy_samples submodules
|
2018-09-28 19:20:15 +00:00
|
|
|
|
|
|
|
submodules:
|
|
|
|
git submodule init
|
2018-12-10 12:30:15 +00:00
|
|
|
git submodule update --recursive --remote
|
2018-09-28 19:20:15 +00:00
|
|
|
|
2018-10-05 09:37:48 +00:00
|
|
|
build: $(DIST_DIR)/index.html $(DIST_DIR)/styles/index.css $(SCRIPT_DEST)
|
2018-09-28 19:20:15 +00:00
|
|
|
|
|
|
|
watch:
|
|
|
|
@echo 'watching for change'
|
|
|
|
@echo 'press Ctrl+C to stop'
|
|
|
|
@while true; do \
|
|
|
|
$(MAKE) --silent build; \
|
|
|
|
sleep 0.5; \
|
|
|
|
done
|
|
|
|
|
|
|
|
serve:
|
|
|
|
node server
|
|
|
|
|
|
|
|
# npm
|
|
|
|
node_modules:
|
|
|
|
npm install
|
|
|
|
|
|
|
|
# vendor lib
|
|
|
|
copy_lib:
|
|
|
|
@node copy_lib.js
|
|
|
|
|
2018-10-17 21:04:03 +00:00
|
|
|
# samples
|
2018-12-17 14:20:36 +00:00
|
|
|
copy_samples: src/config.json
|
|
|
|
|
|
|
|
src/config.json:
|
|
|
|
@cp -n src/config.sample.json src/config.json
|
2018-10-05 11:07:14 +00:00
|
|
|
|
2018-09-28 19:20:15 +00:00
|
|
|
# pug
|
2018-12-17 14:20:36 +00:00
|
|
|
$(DIST_DIR)/index.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
|
|
|
|
@echo pug: $< ➜ $@
|
|
|
|
|
|
|
|
@export ENV="dev"; \
|
|
|
|
node_modules/.bin/pug --pretty $< --out $(dir $@) -O src/config.json || touch $@
|
|
|
|
|
|
|
|
# pug (prod)
|
|
|
|
$(DIST_DIR)/index.prod.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
|
2018-09-28 19:20:15 +00:00
|
|
|
@echo pug: $< ➜ $@
|
2019-04-18 08:01:35 +00:00
|
|
|
|
2018-12-17 14:20:36 +00:00
|
|
|
@export ENV="prod"; \
|
|
|
|
node_modules/.bin/pug --pretty $< --out $(dir $@) -E prod.html -O src/config.json || touch $@
|
2018-09-28 19:20:15 +00:00
|
|
|
|
2019-04-18 08:01:35 +00:00
|
|
|
# pug (staging)
|
|
|
|
$(DIST_DIR)/index.staging.html: src/index.pug src/config.json $(wildcard src/*.pug src/*/*.pug)
|
|
|
|
@echo pug: $< ➜ $@
|
|
|
|
|
|
|
|
@export ENV="staging"; \
|
|
|
|
node_modules/.bin/pug --pretty $< --out $(dir $@) -E staging.html -O src/config.json || touch $@
|
|
|
|
|
2018-09-28 19:20:15 +00:00
|
|
|
# sass
|
2018-10-05 09:37:48 +00:00
|
|
|
$(DIST_DIR)/styles/index.css: src/styles/index.scss $(wildcard src/*.scss src/*/*.scss)
|
2018-09-28 19:20:15 +00:00
|
|
|
@echo sass: $< ➜ $@
|
2018-10-05 09:37:48 +00:00
|
|
|
@node_modules/.bin/node-sass $< $@ --source-map true --source-map-contents || touch $@
|
2018-09-28 19:20:15 +00:00
|
|
|
|
|
|
|
# babel
|
2018-10-22 15:03:00 +00:00
|
|
|
$(DIST_DIR)/%.js: src/%.js .babelrc
|
2018-09-28 19:20:15 +00:00
|
|
|
@echo babel: $< ➜ $@
|
|
|
|
@mkdir -p $(dir $@)
|
|
|
|
@node_modules/.bin/babel $< --out-file $@ --source-maps || touch $@
|
|
|
|
|
2018-10-17 21:04:03 +00:00
|
|
|
buildprod: build
|
2018-12-17 14:20:36 +00:00
|
|
|
$(MAKE) $(DIST_DIR)/index.prod.html
|
2018-10-12 17:11:13 +00:00
|
|
|
|
2018-11-14 13:03:57 +00:00
|
|
|
deploy: pull install build
|
2018-10-17 21:04:03 +00:00
|
|
|
|
|
|
|
pull:
|
|
|
|
git pull
|
|
|
|
|
2019-04-18 08:01:35 +00:00
|
|
|
sync: buildstaging
|
|
|
|
rsync -rv www/* staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ --exclude=www/index.html --exclude=www/index.prod.html --exclude=www/index.staging.html
|
|
|
|
rsync --no-R --no-implied-dirs www/index.staging.html staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/index.html
|
2018-10-18 18:06:43 +00:00
|
|
|
rsync -v www/.htaccess staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/
|
2018-09-28 19:20:15 +00:00
|
|
|
|
2019-04-18 08:01:35 +00:00
|
|
|
sync-prod: buildprod
|
|
|
|
rsync -rv www/* alpha@ssh-alpha.happy-dev.fr:~/alpha.happy-dev.fr/ --exclude=www/index.html --exclude=www/index.prod.html --exclude=www/index.staging.html
|
|
|
|
rsync --no-R --no-implied-dirs www/index.prod.html alpha@ssh-alpha.happy-dev.fr:~/www/index.html
|
|
|
|
rsync -v www/.htaccess alpha@ssh-alpha.happy-dev.fr:~/www/
|
|
|
|
|
2018-10-17 21:04:03 +00:00
|
|
|
.PHONY: default install submodules copy_lib copy_samples build watch serve clean sync buildprod pull deploy
|