Reputation: 8377
I want to compile my es6 code with babel using webpack and then run another script that starts a server in dev mode.
How can I achieve this?
When running the script webpack --watch && node build/index.js
only the first part of the script is executed
Upvotes: 1
Views: 2087
Reputation: 5943
Only the first part is executed because Webpack in watch mode (webpack --watch
) will continue running, and the shell will wait for it to return, because the return value is required for the &&
(AND) operator.
You should run them in parallel. You can use for example concurrently
package (npm install --save-dev concurrently
). And your script would look like this:
concurrently "webpack --watch" "node build/index.js"
This will start both Webpack watch mode and your server, parallelly.
If you want to ensure a complete build before running your dev server, you can add webpack &&
to the beginning of the above script.
Maybe a better way would be to integrate the Webpack watch mode into your dev server, then you would have to start only your dev server.
Upvotes: 4