How to configure pm2 using webpack to write and reload scripts?

Is there any boiler plate code to use pm2with the function webpackfor ts files for automatic hot reset?

pm2 start index.js It is useful to run directly, but how to add a few tasks before doing this, how to watch files and automatically reload using webpack and pm2 from dist folders?

+4
source share
2 answers

I finally stick with this after so many studies looking at performance, I can add a live reboot, which is the todo task. But not a priority at the moment.

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\""
  }
+3
source

process.json pm2 config script webpack. , .

0

Source: https://habr.com/ru/post/1695597/


All Articles