Skip to content

Commit

Permalink
optimize makefile, rebuild only if files changed
Browse files Browse the repository at this point in the history
  • Loading branch information
dmonad committed Dec 12, 2023
1 parent 51b9652 commit 83345be
Show file tree
Hide file tree
Showing 4 changed files with 430 additions and 1,773 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ RUN apt-get update -qq && \
# Copy application code
COPY . .

RUN npm i -g webpack-cli pm2
RUN npm i -g webpack-cli
RUN npm ci
RUN npm run dist:all

Expand All @@ -35,4 +35,4 @@ COPY --from=build /app /app

# Start the server by default, this can be overwritten at runtime
EXPOSE 3000
CMD [ "npm", "run", "pm2"]
CMD [ "npm", "start"]
81 changes: 27 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,61 +1,34 @@
demos = monaco codemirror codemirror.next prosemirror prosemirror-versions quill

all : $(demos)

all :
make -j demos
# remove all generated files
clean :
rm -rf */dist */node_modules node_modules

static-content : all
static-content :
make -j all
rm -rf node_modules */node_modules

demos: monaco cm cm6 pm pm-versions quill

node_modules :
npm ci

# build demo-server
demo-server :
cd demo-server
npm ci
.PHONY demo-server

# build codemirror 5 demo
cm : node_modules
cd codemirror
npm ci
npm run dist

# build codemirror 6 demo
cm6 : node_modules
cd codemirror.next
npm ci
npm run dist

# build prosemirror demo
pm : node_modules
cd prosemirror
npm ci
npm run dist

# build prosemirror-versions demo
pm-versions : node_modules
cd prosemirror-versions
npm ci
npm run dist

# build quill demo
quill : node_modules
cd quill
npm ci
npm run dist

# build monaco demo
monaco : node_modules
cd monaco
npm ci
npm run dist
.PHONY : monaco
$(demos) : % : %/dist
.PHONY : $(demos)

# remove all generated files
clean :
rm -rf */dist */node_modules node_modules
%/node_modules: %/package.json %/package-lock.json
cd $* && npm ci
touch $@

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

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

.SECONDEXPANSION:
%/dist : node_modules %/node_modules $$(filter-out %/dist %/node_modules,$$(wildcard $$*/*))
cd $* && npm run dist
touch $@

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

.ONESHELL :
Loading

0 comments on commit 83345be

Please sign in to comment.