admin管理员组

文章数量:1290980

Is there any boiler plate code to use pm2 with webpack watch option for ts files auto hot reload?

pm2 start index.js is helpful to run directly, but how to add multiple tasks before doing it like watch files and auto reload using webpack and pm2 from dist folders?

Is there any boiler plate code to use pm2 with webpack watch option for ts files auto hot reload?

pm2 start index.js is helpful to run directly, but how to add multiple tasks before doing it like watch files and auto reload using webpack and pm2 from dist folders?

Share Improve this question asked Mar 31, 2018 at 6:25 Mithun ShreevatsaMithun Shreevatsa 3,62910 gold badges58 silver badges104 bronze badges 2
  • why do you need pm2 in your case? Webpack already has some watch options. Is it just for when it crashes? – David Commented Apr 5, 2018 at 15:25
  • 1 pm2 has more benefits pared to webpack. Hence bination of both is worth – Mithun Shreevatsa Commented Apr 6, 2018 at 16:26
Add a ment  | 

2 Answers 2

Reset to default 7

After much research considering performance, I might add live reload, which is a to-do task – but not a priority as of now.

"scripts": {
    "build": "webpack --config webpack.config.js --watch",
    "pm2": "pm2 start ./dist/server.js --watch=true",
    "postinstall": "npm run build",
    "test": "jest --forceExit",
    "test-ci": "npm test && cat ./coverage/lcov.info | coveralls",
    "start": "supervisor ./dist/server.js",
    "server:dev": "concurrently \"npm run build \" \"npm run start\""
}

Create a process.json for pm2 config In the script key you can give a webpack piler to run. I am not sure if it will run for it watch reload.

本文标签: javascriptHow to configure pm2 with webpack for typescripts compile and reloadStack Overflow