Skip to content

Keep Create React App npm scripts working after the Vite migration - #23

Merged
lagergren merged 1 commit into
masterfrom
webapp-cra-script-aliases
Sep 25, 2026
Merged

lagergren merged 1 commit into
masterfrom
webapp-cra-script-aliases

Conversation

@lagergren

Copy link
Copy Markdown
Contributor

Follow-up to #22. That PR replaced Create React App with Vite but dropped CRA's npm scripts, so anyone used to working on welcome/webapp the CRA way would hit errors. This PR restores the familiar commands.

Command Under CRA After #22 With this PR
npm start dev server on http://localhost:3000, opens a browser Missing script: "start" Vite dev server on http://localhost:3000, opens a browser
npm run build production build into build/ same (Vite) unchanged
npm test Jest; the only test looked for "learn react", which the app never rendered, so it always failed Missing script: "test" prints why there are no frontend tests; exits 1
npm run eject copied CRA's hidden config into the project Missing script: "eject" prints that the config is already in vite.config.js
npm run dev / npm run preview n/a Vite commands unchanged
  • vite.config.js: added server: { port: 3000, open: true } to match CRA's dev-server defaults (Vite defaults to port 5173 and doesn't open a browser). BROWSER=none still turns off opening the browser. This only affects the dev server; the production bundle is byte-identical (build/assets/index-CX8gFJVw.js unchanged).
  • README.md:
    • Replaced "requires npm build" with the actual commands (npm install && npm run build); npm build isn't a valid npm command.
    • Added a short note on running the frontend locally, including the Node.js requirement when not using the Node that Gradle downloads.

Neither CRA nor Vite has ever proxied the /welcome/* API calls to the XTC backend, so the dev server shows the page without data. That hasn't changed.

Verification:

  • BROWSER=none npm start: serves / and /src/App.jsx with 200 on port 3000.
  • npm test prints its message and exits 1; npm run eject prints its message and exits 0.
  • npm run build and ./gradlew :welcome:build succeed.

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.
@lagergren
lagergren merged commit 528ffaa into master Sep 25, 2026
2 checks passed
@lagergren
lagergren deleted the webapp-cra-script-aliases branch September 25, 2026 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant