diff --git a/Makefile b/Makefile index 71b462d..fe069ae 100644 --- a/Makefile +++ b/Makefile @@ -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) @@ -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 diff --git a/codemirror.next/package.json b/codemirror.next/package.json index f465e2a..36cbbd7 100644 --- a/codemirror.next/package.json +++ b/codemirror.next/package.json @@ -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" }, diff --git a/codemirror/package.json b/codemirror/package.json index 2da286f..bc166df 100644 --- a/codemirror/package.json +++ b/codemirror/package.json @@ -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" }, diff --git a/monaco/package.json b/monaco/package.json index 15f2a05..2b1d76b 100644 --- a/monaco/package.json +++ b/monaco/package.json @@ -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" }, diff --git a/prosemirror-versions/package.json b/prosemirror-versions/package.json index bab6907..f8bc7f8 100644 --- a/prosemirror-versions/package.json +++ b/prosemirror-versions/package.json @@ -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" }, diff --git a/prosemirror/package.json b/prosemirror/package.json index 82a191e..616ef0a 100644 --- a/prosemirror/package.json +++ b/prosemirror/package.json @@ -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" }, diff --git a/quill/package.json b/quill/package.json index fd0a775..25ee4a3 100644 --- a/quill/package.json +++ b/quill/package.json @@ -5,6 +5,7 @@ "author": "Kevin Jahns ", "license": "UNLICENSE", "scripts": { + "watch": "webpack -w --stats errors-only", "dist": "webpack --mode=production", "start": "webpack serve --open quill.html" },