-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
55 lines (47 loc) · 1.43 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
const gulp = require('gulp');
const webserver = require('gulp-webserver');
const sass = require('gulp-sass');
const mustache = require('gulp-mustache-inverted');
const moment = require('moment');
const fs = require('fs');
const src = './src';
const build = './build';
gulp.task('html', (done) => {
gulp.src(`${build}/**/*.html`);
done();
});
gulp.task('css', (done) => {
gulp.src(`${build}/**/*.css`);
done();
});
gulp.task('sass', (done) => {
gulp.src(`${src}/**/*.scss`)
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(`${build}/css/`));
done();
});
gulp.task('mustache', (done) => {
const resumeData = JSON.parse(fs.readFileSync(`${src}/resume-data.json`, 'utf8'));
resumeData.date = moment().format('MMMM D, YYYY');
gulp.src(`${src}/**/*.mustache`)
.pipe(mustache(resumeData, { extension: '.html' }))
.pipe(gulp.dest(`${build}/`));
done();
});
gulp.task('watch', function (done) {
gulp.watch(`${src}/**/*.mustache`, gulp.series('mustache'));
gulp.watch(`${src}/**/*.json`, gulp.series('mustache'));
gulp.watch(`${build}/**/*.css`, gulp.series('css'));
gulp.watch(`${src}/**/*.scss`, gulp.series('sass'));
done();
});
gulp.task('webserver', (done) => {
gulp.src(`${build}/`)
.pipe(webserver({
livereload: true,
open: true,
port: 8081,
}));
done();
});
gulp.task('default', gulp.parallel(['watch', 'html', 'css', 'sass', 'mustache', 'webserver']), function () { });