# Deploy to production server on shared hosting with gulp with FTP

**URL:** https://discourse.roots.io/t/deploy-to-production-server-on-shared-hosting-with-gulp-with-ftp/4435
**Category:** sage
**Tags:** gulp
**Created:** 2015-08-07T15:06:54Z
**Posts:** 7
**Showing post:** 5 of 7

## Post 5 by @Twansparant — 2015-09-07T08:58:17Z

> [@jakus](#):
>
> Thanks for your sharings on this! If I want to just run gulp for the local files without a deployment, what task would I run?

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.

> [@jakus](#):
>
> As I don’t really want to upload all files each time I run gulp… Or once I’ve done the initial upload will it just upload changed files?

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!

---

_[View the full topic](https://discourse.roots.io/t/deploy-to-production-server-on-shared-hosting-with-gulp-with-ftp/4435)._
