Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NPM command for run Node server after webpack finish building

I want to run a command like: npm run start:dev to make my node server runs but after webpack finished building bundles.

My current npm scripts are:

"scripts": {
    "start": "node server/server.js",
    "start:dev": "npm run build:prod & npm start",
    "lint": "eslint *",
    "build:dev": "webpack",
    "build:prod": "webpack -p --env production",
    "dev-server": "webpack-dev-server",
    "test": "cross-env NODE_ENV=test jest --config=jest.config.json"
},

The current command will kick both operations together.

like image 832
Shadi Altarsha Avatar asked Nov 07 '22 08:11

Shadi Altarsha


1 Answers

Typo: you don't actually want to use &, you want &&:

"start:dev": "npm run build:prod && npm start",

A single ampersand will background the run:build job and cause start to run concurrently.

like image 64
msanford Avatar answered Nov 15 '22 07:11

msanford