Package.json predev script optimization
Unanswered
Buff-bellied Hummingbird posted this in #help-forum

Buff-bellied HummingbirdOP
Hey folks,
Looking for a solution to opening a new tab that mirrors create-react-app's approach. I'd like to only open a new tab on
Looking for a solution to opening a new tab that mirrors create-react-app's approach. I'd like to only open a new tab on
npm run dev
if an existing tab at the specified port is not already open, otherwise focus that existing tab. Curious if anyone has bumped into this and found a solution already.5 Replies

I don't think the focusing thing is every possible but you can write a script which waits for few seconds(until the dev server is ready) to open the new tab, something like what prisma studio does

@Yi Lon Ma I don't think the focusing thing is every possible but you can write a script which waits for few seconds(until the dev server is ready) to open the new tab, something like what prisma studio does

Buff-bellied HummingbirdOP
More important than focusing is to not open a new tab if I already have one open at the specific host.
This is default behavior in CRA and as I’m working on migrating an app and find myself restarting frequently it’s kind of painful ha
This is default behavior in CRA and as I’m working on migrating an app and find myself restarting frequently it’s kind of painful ha

I don't remember that behaviour, I think it just opens a new tab no matter what
need to see for myself

Yoir only option is to write a script that runs in a seperate terminal that monitors the port to check for the dev server being actove and then looking at whatever browser you use to see if its possible to know what tabs are open by code