Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to configure pm2 with webpack for typescripts compile and reload?

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?

like image 372
Mithun Shreevatsa Avatar asked Mar 31 '18 06:03

Mithun Shreevatsa


Video Answer


2 Answers

I am finally sticking with this after so much of research considering performance, i might add live reload which is todo 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\""
  }
like image 105
Mithun Shreevatsa Avatar answered Nov 15 '22 17:11

Mithun Shreevatsa


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

like image 32
DrEarnest Avatar answered Nov 15 '22 17:11

DrEarnest