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?
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.