-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
78 lines (67 loc) · 1.66 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
const gulp = require('gulp');
const php = require('gulp-connect-php');
const browsersync = require("browser-sync");
const ftp = require('vinyl-ftp');
const log = require('fancy-log');
require('dotenv').config();
var localFilesToUpload = [
'index.php',
'.htaccess',
'./kirby/**/*', /* You can comment this out after the first upload, as this folder contains Kirby itself */
'./assets/**/*',
'./content/**/*',
'./site/**/*',
'./site/**/.htaccess'
];
// PHP Server + BrowserSync
function server(done) {
php.server({
base: './',
port: process.env.DEV_phpServerPort,
router: 'kirby/router.php'
}, function (){
browsersync({
injectChanges: true,
port: process.env.DEV_browserSyncPort,
proxy: process.env.DEV_phpProxy + ':' + process.env.DEV_phpServerPort
});
});
done();
}
// BrowserSync Reload
function reload(done) {
browsersync.reload();
done();
}
// Watch files
function watch() {
gulp.watch(
[
"./assets/**/*",
"./content/**/*",
"./site/**/*",
],
reload
);
}
function connect(){
return ftp.create({
host: process.env.FTP_HOST,
port: 21,
user: process.env.FTP_USER,
password: process.env.FTP_PASS,
log: log
});
}
function publish() {
var conn = connect();
return gulp.src(localFilesToUpload, {base: '.', buffer: false})
.pipe(conn.newer(process.env.FTP_DIRECTORY))
.pipe(conn.dest(process.env.FTP_DIRECTORY))
}
// define complex tasks
const dev = gulp.parallel(server, watch);
// export tasks
exports.publish = publish;
exports.dev = dev;
exports.default = dev;