From 4352ebef5135588466bdc75eea512e1cee445695 Mon Sep 17 00:00:00 2001 From: Marcus Lagergren <1062473+lagergren@users.noreply.github.com> Date: Fri, 25 Sep 2026 15:10:48 +0200 Subject: [PATCH] Keep Create React App npm scripts working after the Vite migration npm start runs the Vite dev server on port 3000 and opens a browser, as under CRA. npm test and npm run eject explain why they no longer apply instead of failing with "Missing script". Document the frontend dev workflow and fix the invalid "npm build" instruction in the README. --- README.md | 6 +++++- welcome/webapp/package.json | 5 ++++- welcome/webapp/vite.config.js | 5 +++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index decf9a9..0a3a340 100644 --- a/README.md +++ b/README.md @@ -169,7 +169,7 @@ xtc build -o out chess-game/db/src/main/x/chessDB.x xtc build -o out -L out -r chess-game/app/webapp chess-game/app/src/main/x/chess.x # chess.examples.org is @WebApp — needs the XQIZ.IT platform to host -# Welcome (requires npm build in welcome/webapp/ first) +# Welcome (build the React frontend first: cd welcome/webapp && npm install && npm run build) xtc build -o out -r welcome/webapp welcome/src/main/x/*.x xtc run -L out welcomeTest # standalone DB console app # welcome.examples.org / welcomeCLI.examples.org are @WebApp — need the XQIZ.IT platform @@ -251,6 +251,10 @@ xtc build -o out -L out -r chess-game/app/webapp chess-game/app/src/main/x/chess A "hello world" web application with a React frontend. Demonstrates `@WebApp`, database integration (`oodb`), static content serving, and a CLI management tool. +The frontend in `welcome/webapp` is built with Vite (Node.js 20.19+ or 22.12+ when not using the +Gradle-downloaded Node). `npm start` (or `npm run dev`) serves it on http://localhost:3000 with hot +reload; the `/welcome/*` API calls need the backend hosted on the XQIZ.IT platform. + The `welcomeTest` module is a standalone console app that exercises the database layer directly. It opens a `jsondb` connection to the `welcomeDB` schema, looks up a guest entry in the `counters` map, increments it, and prints the visit count: diff --git a/welcome/webapp/package.json b/welcome/webapp/package.json index 81376d1..3c92ab2 100644 --- a/welcome/webapp/package.json +++ b/welcome/webapp/package.json @@ -12,8 +12,11 @@ "vite": "^8.3.1" }, "scripts": { + "start": "vite", "dev": "vite", "build": "vite build", - "preview": "vite preview" + "preview": "vite preview", + "test": "echo \"No frontend tests: the Create React App boilerplate test was removed in the move to Vite.\" && exit 1", + "eject": "echo \"Nothing to eject: the Vite build configuration is already in vite.config.js.\"" } } diff --git a/welcome/webapp/vite.config.js b/welcome/webapp/vite.config.js index 5d4dbb7..9c2a3fc 100644 --- a/welcome/webapp/vite.config.js +++ b/welcome/webapp/vite.config.js @@ -8,4 +8,9 @@ export default defineConfig({ build: { outDir: 'build', }, + // Keep the Create React App dev-server defaults (port 3000, open a browser) for `npm start`. + server: { + port: 3000, + open: true, + }, });