Gulp Express Nodemon

For our Express.js Node.js page we started using Gulp.js for building static assets but we needed to run gulp to build them, and it wasn't easy to remember to do that before commit (right now we have min files in repository).

For development we are using nodemon to restart the app on every change so I thinked how to integrate nodemon and gulp.

First obvious answer I found was gulp-nodemon but it was really buggy and I had no idea why it's not killing server and trying to run new one all the time. I have even created issue about that, more to seek for help than having any idea what is wrong.

// Gulpfile.js  
var gulp \= require('gulp') , nodemon \= require('gulp-nodemon')


gulp.task('nodemon', function () {
nodemon({ script: 'app.js'})
.on('restart', 'default')
})

After a couple of days I started from scratch but I have new idea, I need to ignore files that I'm building with gulp so that I'm not restarting app all the time. For that I have created nodemon.json in root directory (it is respected by gulp-nodemon). With that change everything started to work.

{  
"verbose": true,
"ignore": ["dist/*"]
}


Share on Hacker News
Share on LinkedIn


← Home


Want to learn more?

Sign up to get a digest of my articles and interesting links via email every month.

* indicates required

Please select all the ways you would like to hear from Krzysztof Kula:

You can unsubscribe at any time by clicking the link in the footer of my emails.

I use Mailchimp as a marketing platform. By clicking below to subscribe, you acknowledge that your information will be transferred to Mailchimp for processing. Learn more about Mailchimp's privacy practices here.