tiny-lr.mk
1.4 KB
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
# Include this file into your makefile to bring in the following targets:
#
# - start - Start the LiveReload server
# - stop - Stops the LiveReload server
# - livereload - alias to start
# - livereload-stop - aias to stop
#
# Then define your "empty" targets, and the list of files you want to monitor.
#
# CSS_DIR = app/styles
# CSS_FILES = $(shell find $(CSS_DIR) -name '*.css')
#
# $(CSS_DIR): $(CSS_FILES)
# @echo CSS files changed: $?
# @touch $@
# curl -X POST http://localhost:35729/changed -d '{ "files": "$?" }'
#
# reload-css: livereload $(CSS_DIR)
#
# .PHONY: reload-css
#
# The pattern is always the same, define a target for your root directory that
# triggers a POST request and `touch` the directory to update its mtime, a
# reload target with `livereload` target and the list of files to "watch" as
# prerequisites
#
# You can chain multiple "reload" targets in a single one:
#
# reload: reload-js reload-css reload-img reload-EVERYTHING
# add tiny-lr to your PATH (only affect the Makefile environment)
PATH := ./node_modules/.bin:$(PATH)
tiny-lr.pid:
@echo ... Starting server, running in background ...
@echo ... Run: "make stop" to stop the server ...
@tiny-lr &
start: tiny-lr.pid
stop:
@[ -a tiny-lr.pid ] && curl http://localhost:35729/kill
# Or: @[ -a tiny-lr.pid ] && kill $(shell cat tiny-lr.pid)
livereload: start
livereload-stop: stop
.PHONY: start stop livereload livereload-stop