feat: move essays of 2014

This commit is contained in:
Stefan Imhoff
2023-06-04 11:40:57 +02:00
parent 79a2b6e94a
commit 2886aafbf9
25 changed files with 2831 additions and 3 deletions

View File

@@ -0,0 +1,85 @@
---
title: "Introduction to Gulp.js 14: Deploying the Website with Rsync"
slug: gulp-tutorial-14-deploying-the-website
author: Stefan Imhoff
date: 2014-10-31T08:00:00+02:00
description: "The ultimate tutorial and guide for Gulp.js: How to deploy your website with rsync to your server."
cover: /assets/images/cover/gulp.svg
tags: ["code"]
series: gulp
---
This is the 14th of my series _Introduction to Gulp.js_. Today I will write a task to sync the files of my Jekyll site to my web server.
## Deploying the Website
There are plenty of possibilities to get a website on the server. You may use FTP, SFTP, SCP, SCP2, Rsync, or Git. I use Rsync because its fast and easy to use.
I write another task as an entry point: `deploy`
#### gulp/tasks/deploy.js
```javascript
var gulp = require("gulp");
/**
* Start rsync task
*/
gulp.task("deploy", ["rsync"]);
```
This will start the `rsync` task. But I could add more tasks, for example, a task, which creates a zip archive of the build and copies it to a backup on my hard drive.
```bash
$ npm install --save-dev gulp-rsync@0.0.5
```
#### gulp/config.js
```javascript
rsync: {
src: production + '/**',
options: {
destination: '~/path/to/my/website/root/',
root: production,
hostname: 'mydomain.com',
username: 'user',
incremental: true,
progress: true,
relative: true,
emptyDirectories: true,
recursive: true,
clean: true,
exclude: ['.DS_Store'],
include: []
}
}
```
This task will grab all files in my production folder, connect to my server, and copy all files recursively to my website root. It will delete old files and add changes to the server.
#### gulp/tasks/production/rsync.js
```javascript
var gulp = require("gulp");
var rsync = require("gulp-rsync");
var config = require("../../config").rsync;
/**
* Copy files and folder to server
* via rsync
*/
gulp.task("rsync", function () {
return gulp.src(config.src).pipe(rsync(config.options));
});
```
## Conclusion
This concludes the series _Introduction to Gulp.js_. Developing and deploying with Gulp.js is fun.
I like the UNIX philosophy of Gulp.js: Having small files, which do one task and connect these to larger workflows. And because I kept my Gulp.js tasks small, pluggable, and shareable, I was able to add Gulp.js to my second website in less than five minutes.
<Figure>
<MoreLink href="https://github.com/kogakure/gulp-tutorial" text="View Source on GitHub" />
</Figure>