-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
90 lines (71 loc) · 2.03 KB
/
gulpfile.babel.js
File metadata and controls
90 lines (71 loc) · 2.03 KB
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
79
80
81
82
83
84
85
86
87
88
89
'use strict';
import gulp from "gulp"
import http from "http"
import mjml from "gulp-mjml"
import data from "gulp-data"
import pug from "gulp-pug2"
import del from "del"
import lr from "tiny-lr"
import fetch from "node-fetch"
import deploy from "gulp-gh-pages"
import ecstatic from "ecstatic"
import refresh from "gulp-livereload"
import embedlr from "gulp-embedlr"
import mjmlEngine from "mjml"
import express from "express"
const dir = {
dest: './dist'
};
const httpPort = 5000;
const livereload = lr();
const livereloadPort = 35729;
gulp.task('express', () => {
var app = express();
app.set('views', './views')
app.set('view engine', 'pug')
});
// app.get('/', function (req, res) {
// res.render('index', { title: 'Hey', message: 'Hello there!' })
// })
// gulp.task('clean', () => {
// return del([dir.dest]);
// });
gulp.task('img', () => {
return gulp.src(["./sources/**/*.png", "./sources/**/*.jpg"])
.pipe(gulp.dest(dir.dest))
.pipe(refresh(livereload));
});
gulp.task('pug', () => {
return gulp.src("./sources/**/*.pug")
.pipe(data((file, callback) => {
fetch('http://devternity.com/js/event.js')
.then(function(res) {
return res.json();
})
.then(function(jsn) {
return callback(undefined, jsn[0])
})
}))
.pipe(pug())
.pipe(mjml(mjmlEngine, {minify: true}))
// .pipe(embedlr())
.pipe(gulp.dest(dir.dest))
.pipe(refresh(livereload));
});
gulp.task('serve', () => {
http.createServer(ecstatic({root: dir.dest})).listen(httpPort);
livereload.listen(livereloadPort);
});
gulp.task('watch', () => {
gulp.watch(["./sources/**/*.pug"], ['pug']);
gulp.watch(["./sources/**/*.png", "./sources/**/*.jpg"], ['img']);
});
gulp.task('deploy', function () {
var options = {
remoteUrl: "https://github.com/devternity/media.git",
branch: "gh-pages"
};
return gulp.src(['./dist/**/*']).pipe(deploy(options));
});
gulp.task('build', ['pug', 'img']);
gulp.task('default', ['express']);