about summary refs log tree commit diff
path: root/web/GNUmakefile
blob: a1738faf06f8002da2eabc96cbc142f5a319cd9f (plain) (blame)
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
# Directory where the build output should be written to
DIST ?= dist
# Change this to "development" for source maps and non-minifyed code
NODE_ENV ?= production
# If true, we don't attempt to fetch dependencies via yarn
OFFLINE ?= false

ifeq ($(NODE_ENV),production)
ESBUILDFLAGS  = --minify
else
ESBUILDFLAGS  = --sourcemap
endif

ESBUILDFLAGS += --platform=browser --bundle
ESBUILDFLAGS += --target=es6,edge79,firefox54,chrome51,safari11

ESBUILD ?= esbuild
ESBUILD += $(ESBUILDFLAGS)

INSTALL ?= install
INSTALL += -m644

all: dist/main.js dist/index.html dist/custom.css dist/vis-network.min.css

$(DIST):
	mkdir -p $@

node_modules:
	$(OFFLINE) || yarn install --frozen-lockfile --prod

$(DIST)/vis-network.min.css: node_modules $(DIST)
	$(ESBUILD) node_modules/vis-network/dist/dist/vis-network.min.css --outfile=$@

$(DIST)/%.js: source/%.js $(DIST) node_modules
	$(ESBUILD) $< --outfile=$@

$(DIST)/%.css: source/%.css $(DIST)
	$(ESBUILD) $< --outfile=$@

$(DIST)/%: source/% $(DIST)
	$(INSTALL) $< $@

clean:
	rm -rf $(DIST)
	rm -rf node_modules

.PHONY: clean node_modules