reorganizar el makefile
* la tarea por defecto es mostrar la ayuda (con colores!) * instala las dependencias siempre * usa hainish * usa nginx como servidor de desarrollo, ver sutty/haini.sh!7
This commit is contained in:
parent
47c68010a3
commit
01d1a4837f
1 changed files with 34 additions and 24 deletions
58
Makefile
58
Makefile
|
@ -1,10 +1,13 @@
|
|||
SHELL := bash
|
||||
.DEFAULT_GOAL := all
|
||||
.DEFAULT_GOAL := help
|
||||
|
||||
site ?= $(patsubst %-jekyll-theme,%,$(notdir $(PWD)))
|
||||
domain ?= $(site).sutty.local
|
||||
env ?= production
|
||||
JEKYLL_ENV ?= $(env)
|
||||
env ?= development
|
||||
hainish ?= ../haini.sh/haini.sh
|
||||
hain ?= ../hain
|
||||
|
||||
JEKYLL_ENV := $(env)
|
||||
|
||||
.env:
|
||||
@touch .env
|
||||
|
@ -12,34 +15,27 @@ include .env
|
|||
|
||||
export
|
||||
|
||||
node_modules: package.json ## Instala las dependencias solo cuando cambian
|
||||
yarn
|
||||
help: always ## Ayuda
|
||||
@grep "^\w\+:.*##" Makefile | sed -re "s/(\w+):.*##(.*)/\x1B[38;5;197m\1\x1B[0m\t\t\2/" # | column -s ";" -t
|
||||
|
||||
all: node_modules fa build ## Instalar dependencias y compilar el sitio
|
||||
all: node_modules fa install serve build ## Todas las tareas necesarias para desarrollar
|
||||
|
||||
install: node_modules Gemfile.lock ## Instalar las dependencias
|
||||
|
||||
build: ## Compilar el sitio
|
||||
bundle exec jekyll build --profile --trace
|
||||
make bundle args="exec jekyll build --profile --trace"
|
||||
@echo -e "\a"
|
||||
|
||||
serve: /etc/hosts kill-servers ## Servidor de prueba
|
||||
@echo "Iniciando servidor web en https://$(domain):4000/"
|
||||
@if ! ss -lnp | grep -q :65000 ; then nghttpd -d _site/ 65000 ../sutty.local/domain/sutty.local.{key,crt} & echo $$! > /tmp/nghttpd.pid ; fi
|
||||
@if ! ss -lnp | grep -q :4000 ; then nghttpx -b "127.0.0.1,65001;/assets/js/:/sockjs-node/" -b "$(domain),65000;/;proto=h2;tls" -f "0.0.0.0,4000" -L FATAL --no-ocsp ../sutty.local/domain/sutty.local.{key,crt} & echo $$! > /tmp/nghttpx.pid ; fi
|
||||
bundle: ## Correr comandos con bundler (args="install")
|
||||
$(hainish) 'bundle $(args)'
|
||||
|
||||
kill-servers: /tmp/nghttpd.pid /tmp/nghttpx.pid /tmp/webpack.pid ## Cerrar el servidor
|
||||
serve: /etc/hosts $(hain)/run/nginx/nginx.pid ## Servidor de desarrollo
|
||||
@echo "Iniciado servidor web en https://$(domain):4000/"
|
||||
|
||||
webpack: assets/js/pack.js ## Compilar JS
|
||||
@echo -e "\a"
|
||||
|
||||
webpack-dev-server: /tmp/webpack.pid ## Servidor de prueba de Webpack
|
||||
./node_modules/.bin/webpack-dev-server --public $(domain):4000 --host 127.0.0.1 --port 65001 & echo $$! > /tmp/webpack.pid
|
||||
|
||||
# Tomar los códigos de los íconos de este archivo y copiarlos a fa.txt
|
||||
# node_modules/font-awesome/scss/_variables.scss
|
||||
assets/fonts/forkawesome-webfont.woff2: fa.txt
|
||||
which glyphhanger || npm i -g glyphhanger
|
||||
grep -v "^#" fa.txt | sed "s/^/U+/" | tr "\n" "," | xargs -rI {} glyphhanger --subset=node_modules/fork-awesome/fonts/forkawesome-webfont.ttf --formats=woff2 --whitelist="{}"
|
||||
mv node_modules/fork-awesome/fonts/forkawesome-webfont-subset.woff2 $@
|
||||
|
||||
fa: assets/fonts/forkawesome-webfont.woff2 ## Fork Awesome
|
||||
@echo -e "\a"
|
||||
|
@ -48,16 +44,30 @@ push: ## Publica los cambios locales
|
|||
sudo chgrp -R 82 _site
|
||||
rsync -avi --delete-after _site/ root@athshe.sutty.nl:/srv/sutty/srv/http/data/_deploy/$(site).sutty.nl/
|
||||
|
||||
node_modules: package.json
|
||||
yarn
|
||||
|
||||
Gemfile.lock: Gemfile
|
||||
$(hainish) 'bundle install'
|
||||
|
||||
$(hain)/run/nginx/nginx.pid:
|
||||
$(hainish) nginx
|
||||
|
||||
/tmp/webpack.pid:
|
||||
./node_modules/.bin/webpack-dev-server --public $(domain):4000 --host 127.0.0.1 --port 65001 & echo $$! > /tmp/webpack.pid
|
||||
|
||||
/etc/hosts: always
|
||||
@echo "Chequeando si es necesario agregar el dominio local $(domain)"
|
||||
@grep -q " $(domain)$$" $@ || echo -e "127.0.0.1 $(domain)\n::1 $(domain)" | sudo tee -a $@
|
||||
|
||||
%.pid: always
|
||||
@test -f $@ && cat $@ | xargs -r kill &>/dev/null || :
|
||||
@rm -f $@
|
||||
|
||||
js = $(wildcard _packs/*.js) $(wildcard _packs/*/*.js) $(wildcard *.js)
|
||||
assets/js/pack.js: $(js)
|
||||
./node_modules/.bin/webpack --config webpack.prod.js
|
||||
|
||||
# Tomar los códigos de los íconos de este archivo y copiarlos a fa.txt
|
||||
# node_modules/font-awesome/scss/_variables.scss
|
||||
assets/fonts/forkawesome-webfont.woff2: fa.txt
|
||||
grep -v "^#" fa.txt | sed "s/^/U+/" | tr "\n" "," | xargs -rI {} glyphhanger --subset=node_modules/fork-awesome/fonts/forkawesome-webfont.ttf --formats=woff2 --whitelist="{}"
|
||||
mv node_modules/fork-awesome/fonts/forkawesome-webfont-subset.woff2 $@
|
||||
|
||||
.PHONY: always
|
||||
|
|
Loading…
Reference in a new issue