Deploy to production server on shared hosting with gulp with FTP

Good question, which I haven’t figured out yet unfortunately…
In previous versions, you just ran gulp build but in Sage just gulp also runs the build task.

It does yes with the following line:

.pipe( conn.newer( '/public_html/web/app/themes/sage' ) )

However the problem is that the entire dist folder gets rebuild on gulp --production which causes the entire folder to get re-uploaded on every build.

Another thing I just bumped into, is that the previous hashed versions of the minified files don’t get deleted from the ftp server. So I tried to add the following line which should delete the remote dist folder entirely before uploading:

.pipe( conn.rmdir( '/domains/mydomain.com/public_html/web/app/themes/sage/dist' ), cb )

Which does delete the folder, but it gives me a bunch of errors too:

[10:28:57] TypeError: Cannot read property 'on' of undefined
[10:28:57] TypeError: Cannot read property 'on' of undefined
/pathto/site/web/app/themes/sage/node_modules/vinyl-ftp/lib/delete.js:53
                        cb( err );
                        ^
TypeError: undefined is not a function

So I placed a callback function within the task:

gulp.task('upload', function(cb) {
  cb();
  ...
});

But that doesn’t work. I’m not that familiar (yet) with the gulp syntax.
Where should I place the callback and what should go in it?

Could someone give us a hand?
Thanks!