Search code examples
javascripttypescriptexpresswebpackpm2

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?


Solution

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