Reputation: 11097
We have an application that has the following three scripts inside package.json...
"start": "concurrently --kill-others \"npm run start-electron\" \"npm run start-webpack\" -n \"electron,webpack\" -p name",
"start-electron": "electron -r babel-register ./js-file",
"start-webpack": "node -r babel-register scripts/js-file-2.js"
When we run npm start
, both start-electron
and start-webpack
scripts are called. We are using Concurrently to run both scripts at the same time.
There is a major issue. When we start the Webpack script, it makes a HTTP request to the Node server. Because these two scripts are running concurrently, we can't guarantee the Node server will be running when we run the Webpack script.
Here's my question. How can I run the Webpack script as soon as the Node server starts and avoid this race condition?
Upvotes: 2
Views: 1893
Reputation: 12796
Do they really need to run next to each other? Any chance that you could create a node program that launches electron
, and either checks if it's running or waits a certain amount of time before running the webpack
command?
As an idea you could implement something like this:
I guess both commands stay alive (webpack is probably watching files, electron manages the server).
You could check into integrations between electron and webpack, for example, this one
Upvotes: 2