Skip to content

Commit

Permalink
optimized serve - watch files for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Dec 12, 2023
1 parent 83345be commit ae6ea2b
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 13 deletions.
43 changes: 30 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
demos = monaco codemirror codemirror.next prosemirror prosemirror-versions quill
dists = $(patsubst %,%/dist,$(demos))
node_modules = $(patsubst %,%/node_modules,$(demos)) demo-server/node_modules

all : $(demos)

Expand All @@ -10,25 +12,40 @@ static-content :
make -j all
rm -rf node_modules */node_modules

$(demos) : % : %/dist
.PHONY : $(demos)

%/node_modules: %/package.json %/package-lock.json
$(node_modules) : %/node_modules: %/package.json %/package-lock.json
cd $* && npm ci
touch $@
@touch $@

.NOTINTERMEDIATE: $(patsubst %,%/node_modules,$(demos))
.NOTINTERMEDIATE: $(node_modules)

node_modules : package.json package-lock.json
-npm ci
-touch node_modules
npm ci
@touch node_modules

.SECONDEXPANSION:
%/dist : node_modules %/node_modules $$(filter-out %/dist %/node_modules,$$(wildcard $$*/*))

ifeq ($(MAKECMDGOALS),serve)
$(dists) : %/dist : %/node_modules node_modules
cd $* && npm run watch
.PHONY: $(dists)
else
$(dists) : %/dist : node_modules %/node_modules $$(filter-out %/dist %/node_modules,$$(wildcard $$*/*))
cd $* && npm run dist
touch $@
@touch $@
endif

.PHONY: serve
serve : $(demos) demo-server/node_modules
cd demo-server && npm start
$(demos) : % : %/dist
.PHONY : $(demos)

demo-server : $(node_modules) node_modules
cd demo-server && npm start
.PHONY : demo-server

# Build & watch all scripts. Also start the demo-server
# Requires parallel execution of make targets
ifneq (,$(findstring -j,-$(MAKEFLAGS)))
serve: demo-server $(demos)
else
serve:
@$(MAKE) -j serve
endif
1 change: 1 addition & 0 deletions codemirror.next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Yjs ❤ CodeMirror",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack serve --open --open-page codemirror.next.html"
},
Expand Down
1 change: 1 addition & 0 deletions codemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Yjs ❤ CodeMirror",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack serve --open --open-page codemirror.html"
},
Expand Down
1 change: 1 addition & 0 deletions monaco/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"description": "Yjs ❤ Monaco",
"main": "index.js",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack serve --open --open-page monaco.html"
},
Expand Down
1 change: 1 addition & 0 deletions prosemirror-versions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Yjs ❤ ProseMirror + versioning support",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack serve --open prosemirror-versions.html"
},
Expand Down
1 change: 1 addition & 0 deletions prosemirror/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "1.0.0",
"description": "Yjs ❤ ProseMirror",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack server --open prosemirror.html"
},
Expand Down
1 change: 1 addition & 0 deletions quill/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "Kevin Jahns <[email protected]>",
"license": "UNLICENSE",
"scripts": {
"watch": "webpack -w --stats errors-only",
"dist": "webpack --mode=production",
"start": "webpack serve --open quill.html"
},
Expand Down

0 comments on commit ae6ea2b

Please sign in to comment.