Perhaps the best way to do this is within your package.json. In there you will see (among others) the dev script with something like vite dev. In order to run this script on startup, just ensure it runs before the original command. For example, something like this:
sh ./pocketbase/pocketbase.sh && vite dev
This will get you covered for the dev environment. As per the prod environment (if needed), you will need to figure it out what command you need and do the same. For example, as I use the node adapter, the command I use to run the project is node build/index.js so, if this was also yours, you could add the prod command into your package.json like this:
sh ./pocketbase/pocketbase.sh && node build/index.js
And then you could run it with npm run prod.
Other options would be to execute a command from javascript itself but I think running it from package.json is far better and simpler.
2
Answers
Perhaps the best way to do this is within your
package.json
. In there you will see (among others) thedev
script with something likevite dev
. In order to run this script on startup, just ensure it runs before the original command. For example, something like this:This will get you covered for the dev environment. As per the prod environment (if needed), you will need to figure it out what command you need and do the same. For example, as I use the node adapter, the command I use to run the project is
node build/index.js
so, if this was also yours, you could add theprod
command into yourpackage.json
like this:And then you could run it with
npm run prod
.Other options would be to execute a command from javascript itself but I think running it from
package.json
is far better and simpler.I’m using concurrently
pnpm/npm -D install concurrently
Instead of my command
cd backend && go run main.go serve --http=127.0.0.1:8080
replace it with yours, because i’m using pocketbase as a framework