This is an easy way publish your site with rsynch to serve the generated static files.
Install the gulp-rsync gulp plugin:
$ npm install --save-dev gulp-rsync
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"
}
Add this task to your gulpfile.js
. It will run build
task before deploying:
gulp.task('deploy', ['build'], () => {
const rsyncConfig = require('./rsync.json');
return gulp.src('dist/**')
.pipe($.rsync({
root: 'dist',
hostname: rsyncConfig.hostname,
username: rsyncConfig.username,
destination: rsyncConfig.destination,
progress: true
}));
});
Run the following command to deploy:
$ gulp deploy
It is highly recommended to enable asset revisioning.
You can add rsync.json
file to .gitignore
to protect your connection data.
/rsync.json