New blog domain: kula.blog

It's still work in progress but new posts will be published on  https://kula.blog/ Thanks to 11ty base blog RSS is working from the start so it should be easy to add to your reader if you still use any :) If now then I hope you can sign up to the newsletter where I'll be publishing new posts and interesting articles to it from time to time. Please use  kula.blog  from now on.

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/*"]
}

Comments

Popular posts from this blog

How to use NPM packages from private repositories on bitbucket

How to simulate slow connection (developer proxy in Node.js)