Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Gulp with PM2?

I'm using Gulp to compile and minify SCSS, Pug, JSX and that sort of things. So in the development process as usual I'm opening the terminal window and typing gulp and it watches my files. But I have to keep open the terminal window and Gulp tab, otherwise my files don't be compiled.

I'm using PM2 too. When I wanna start a Node job I just write pm2 start file.js --watch and pm2 startup in order to start the script on operating system opening. I wanna do the same thing for Gulp. I've tried like pm2 start gulpfile.js --watch, but it doesn't work.

How can I use Gulp with PM2?

like image 910
ozgrozer Avatar asked Dec 10 '25 01:12

ozgrozer


1 Answers

I am no expert in gulp, but you can execute your gulp command via pm2 by defining it in the process file at your project root.

ecosystem.json

{
    "apps": [
        {
            "name": <name_of_your_app>,
            "script": "gulp"
        }
    ]
}

Then, from terminal, run $ pm2 start ecosystem.json. You can also define watch options at that process file. See this for more details.

like image 118
SALEH Avatar answered Dec 12 '25 14:12

SALEH



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!