DIST_DIR := www SCRIPT_SRC := $(wildcard src/scripts/*.js) SCRIPT_DEST := $(SCRIPT_SRC:src/%=$(DIST_DIR)/%) default: build clean: git clean -fXd -e !src/config.json install: node_modules copy_lib copy_samples build: $(DIST_DIR)/index.html $(DIST_DIR)/styles/index.css $(SCRIPT_DEST) 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 # samples copy_samples: src/config.json src/config.json: @cp -n src/config.sample.json src/config.json # pug $(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) @echo pug: $< ➜ $@ @export ENV="prod"; \ node_modules/.bin/pug --pretty $< --out $(dir $@) -E prod.html -O src/config.json || touch $@ # 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 $@ # sass $(DIST_DIR)/styles/index.css: src/styles/_index.scss $(wildcard src/*.scss src/*/*.scss src/*/*/*.scss src/*/*/*/*.scss) @echo sass: $< ➜ $@ @node_modules/.bin/node-sass $< $@ --source-map true --source-map-contents || touch $@ # babel $(DIST_DIR)/%.js: src/%.js .babelrc @echo babel: $< ➜ $@ @mkdir -p $(dir $@) @node_modules/.bin/babel $< --out-file $@ --source-maps || touch $@ buildstaging: build $(MAKE) $(DIST_DIR)/index.staging.html buildprod: build $(MAKE) $(DIST_DIR)/index.prod.html deploy: pull install build pull: git pull 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 rsync -v www/.htaccess staging-app@ssh-staging-app.happy-dev.fr:~/staging-app.happy-dev.fr/ syncprod: buildprod rsync -rv www/* alpha@ssh-alpha.happy-dev.fr:~/www/ --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/ .PHONY: default install copy_lib copy_samples build watch serve clean sync syncprod buildstaging buildprod pull deploy