From a3ed1b64ceb24511304ba3197a01d40e1fb97dd7 Mon Sep 17 00:00:00 2001 From: hewhodevs Date: Wed, 10 Aug 2022 17:07:31 +0930 Subject: [PATCH] Setup concurrently script with wait-on - Using concurrently to launch electron once react is running - "start-react" script launches react with BROWSER=none to prevent default opening of a browser tab at launch - "start-electron" script launches electron once wait-on received http 200 status code from http://127.0.0.1:3000 - Had to use 127.0.0.1 instead of "localhost" in the wait-on url, as wait-on can hang trying to resolve localhost. see wait-on github issues for further details (https://github.com/jeffbski/wait-on/issues/109) - Updated start script in package.json - running npm start now launches react with BROWSER=none using cross-env, then launches electron-start to launch electron after the wait-on is successful --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index 88c209c..483c45f 100644 --- a/package.json +++ b/package.json @@ -17,11 +17,12 @@ "web-vitals": "^2.1.4" }, "scripts": { - "start": "react-scripts start", + "start": "concurrently \"npm run start-react\" \"npm run start-electron\"", + "start-react": "cross-env BROWSER=none react-scripts start", + "start-electron": "wait-on http-get://127.0.0.1:3000 && electron .", "build": "react-scripts build", "test": "react-scripts test", - "eject": "react-scripts eject", - "start-electron": "electron ." + "eject": "react-scripts eject" }, "eslintConfig": { "extends": [