Skip to content

Commit

Permalink
Add a js dev server
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Feb 4, 2024
1 parent a414b8a commit 0f82392
Show file tree
Hide file tree
Showing 5 changed files with 1,200 additions and 1 deletion.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
_opam
_build
node_modules
.vscode
*main.bc.js
*main.bc.js
14 changes: 14 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
_opam:
opam switch create . --no-install --yes

.PHONY: dev-env
dev-env: _opam
opam install . --deps-only --with-test --yes
ocaml-platform
yarn

.PHONY: dev
dev:
sh scripts/build_and_serve.sh

.DEFAULT_GOAL := dev
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "ocamix",
"version": "1.0.0",
"description": "A web-based playlist creator",
"main": "example/index.html",
"repository": "[email protected]:voodoos/ocamix.git",
"author": "Ulysse Gérard <[email protected]>",
"license": "AGPL-3.0",
"dependencies": {},
"scripts": {
"dev": "web-dev-server --root-dir example/ --open --watch"
},
"devDependencies": {
"@web/dev-server": "^0.4.0"
}
}
15 changes: 15 additions & 0 deletions scripts/build_and_serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
opam exec -- dune build @default --watch --terminal-persistence=preserve &
DUNE_PID=$!
yarn run dev &
SERVER_PID=$!

stop() {
echo '\n' Killing servers;
kill ${SERVER_PID}
kill ${DUNE_PID}
exit
}
trap stop SIGINT

wait ${SERVER_PID}
kill ${DUNE_PID}
Loading

0 comments on commit 0f82392

Please sign in to comment.