index: demos
To use a given basic-demo
as a template for a new myproject
:
$ npx degit pmndrs/examples/demos/basic-demo myproject
$ code myproject
$ npm ci
$ npm run dev
$ npm run build
Then npx serve out
.
This will:
- execute
^build2
which willvite build
eachdemos/*
with:
- a
--base
set to${BASE_PATH}/${app_name}
- a custom vite
--config
, whith amonkey()
plugin that will:deterministic
script intosrc/index.jsx
- monkeypatch the
<Canvas>
withCheesyCanvas
for setting up the scene for playwright screenshots
- build the Next.js
apps/website
- copy final result into
out
folder
[!TIP] This is totally fine
BASE_PATH
/BASE_URL
to be unset/empty. But for debug purposes(to be 1:1 with GitHub pages) you can:$ BASE_PATH=/examples BASE_URL=http://localhost:4000 npm run build $ npx serve out -p 4000
$ npm test
To update the snapshots: npm test -- -- --update-snapshots
You can also:
$ BASE_PATH=/examples npm test
For generating reproductible snapshots, we use mcr.microsoft.com/playwright:v1.45.3-jammy
Docker image.
$ docker run -it --rm \
-w /app -v "$(pwd)":/app -v /app/node_modules \
mcr.microsoft.com/playwright:v1.45.3-jammy /bin/sh
#
# echo "Hey, I am acting like the CI"
#
# npm ci
# npm test
or in one command to update snapshots:
docker run --rm \
-w /app -v "$(pwd)":/app -v /app/node_modules \
mcr.microsoft.com/playwright:v1.45.3-jammy /bin/sh -c "npm ci && npm test -- -- --update-snapshots"