0

I built my own webpack.config.js for react development, also I use lite-server. Is it possible to put both webpack and lite-server commands to package.json like that:

"scripts": {
  "dev": "lite-server webpack"
}

or are there any other ways to do that?

ivankoleda
  • 340
  • 1
  • 11

1 Answers1

0

If you want to run 2 commands sequential from package.json script you can use "anding" like this:

"scripts": {
  "dev": "lite-server && webpack"
}

It first runs command lite-server followed by run of webpack if lite-server did not fail.

For concurrent execution I would recommend https://www.npmjs.com/package/concurrently package.

There is also https://www.npmjs.com/package/npm-run-all but I have not tested it myself.

ikettu
  • 1,203
  • 12
  • 17
  • I tried this, but the second one waits for the first to finish, and that will never happen. Also I tried this `"scripts": { "dev": "webpack && lite-server" }` but webpack is in watching mode, so it will never finish by itself. Is there any other possible way to run them both at the same time just with `npm run dev`? – ivankoleda Jul 27 '17 at 10:28
  • You could use npm packages I mention on edited post for concurrent run. – ikettu Jul 27 '17 at 10:37