Skip to content

Latest commit

 

History

History
74 lines (53 loc) · 1.3 KB

rsync-deploy.md

File metadata and controls

74 lines (53 loc) · 1.3 KB

Rsync Deploying

This is an easy way publish your site with rsync to serve the generated static files.

Steps

1. Install dependencies

Install the gulp-rsync gulp plugin:

$ npm install --save-dev gulp-rsync

2. Create a rsync config file

Add a file to project root rsync.json.

{
  "hostname": "hostname or ip",
  "username": "username",
  "destination": "folder"
}

For example:

{
  "hostname": "example.com",
  "username": "user1",
  "destination": "/home/httpd/website"
}

3. Create a deploy task

Add this task to your gulpfile.js. It will run build task before deploying:

function rsync() {
  const rsyncConfig = require('./rsync.json');

  return src('dist/**')
    .pipe($.rsync({
      root: 'dist',
      hostname: rsyncConfig.hostname,
      username: rsyncConfig.username,
      destination: rsyncConfig.destination,
      progress: true
  }));
});

const deploy = series(build, rsync);

exports.deploy = deploy;

4. Deploy

Run the following command to deploy:

$ gulp deploy

Tips

It is highly recommended to enable asset revisioning.

You can add rsync.json file to .gitignore to protect your connection data.

/rsync.json