-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
56 lines (37 loc) · 1.01 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
PROJECT=byways.org
BUILD_DIR?=/var/www/$(PROJECT)
PORT ?= 3040
NODE_BIN=./node_modules/.bin
SRC_DIR=contents
SRC = $(wildcard $(SRC_DIR)/scripts/*.js)
all: check build
FILES = $(shell find $(SRC_DIR) -type f)
OUT_FILES := $(FILES:.md=.html)
OUT_FILES := $(OUT_FILES:%.yaml=%)
OUT_FILES := $(OUT_FILES:.styl=.css)
OUT_FILES := $(OUT_FILES:$(SRC_DIR)/%=$(BUILD_DIR)/%)
SCRIPTS = $(SRC:$(SRC_DIR)/%.js=$(BUILD_DIR)/%.js)
check: lint
clean:
@rm -rf $(BUILD_DIR)/*
distclean: clean
@rm -rf node_modules
.SECONDARY: $(OUT_FILES)
$(OUT_FILES): metalsmith
metalsmith: | node_modules ${BUILD_DIR}
node metalsmith --destination ${BUILD_DIR}
.PHONY: metalsmith
preview: | node_modules ${BUILD_DIR}
node metalsmith --preview --destination ${BUILD_DIR} --port $(PORT)
$(BUILD_DIR):
mkdir -p $@
chown $(USER) $@
lint: | node_modules
$(NODE_BIN)/jshint metalsmith.js $(SRC)
node_modules:
yarn && touch $@
build: $(OUT_FILES)
dist: export NODE_ENV=production
dist: clean check
dist: build
.PHONY: all preview build lint clean