1

I use a web application that runs Python fast API in the backend and electron+vite+vue in the frontend. How can we build and run both the front end and the backend in the same shell? I found one way to run a script to build a Python backend in package.json. Is this good practice? If not what are the alternatives?

Thanks

ghana
  • 63
  • 9
  • Does this answer your question? [How do you run multiple programs in parallel from a bash script?](https://stackoverflow.com/questions/3004811/how-do-you-run-multiple-programs-in-parallel-from-a-bash-script) – sudden_appearance May 04 '23 at 18:35

1 Answers1

0

To build and run both the frontend and backend in the same shell, you can use a tool like concurrently or npm-run-all. These tools allow you to run multiple commands simultaneously in the same terminal window.

Install concurrently:

npm install concurrently --save-dev

Modify the "scripts" section of your package.json to include a new "dev" script that runs both the backend and frontend:

"scripts": { "dev": "concurrently \"cd backend && uvicorn main:app --reload\" \"cd frontend && npm run dev\"" }

Run the "dev" script:

npm run dev
yukthi
  • 11
  • 3