简体   繁体   中英

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?

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\""
  }

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM