forked from omgmog/uxofvr.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
66 lines (57 loc) · 1.64 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
var deploy = require('gulp-gh-pages');
var gulp = require('gulp');
var twig = require('gulp-twig');
var replaceExtension = require('gulp-ext-replace');
var sass = require('gulp-sass');
var yaml = require('js-yaml');
var fs = require('fs');
var cleanCSS = require('gulp-clean-css');
var htmlmin = require('gulp-htmlmin');
var paths = {
dist: './dist/',
allDist: './dist/**/*',
src: './src/',
allSrc: './src/**/*',
liquidSrc: './src/*.twig',
sassSrc: './src/assets/*.scss',
ymlSrc: './src/data.yml'
};
gulp.task('build:html', function () {
var yamlData = yaml.safeLoad(fs.readFileSync(paths.ymlSrc, 'utf8'));
return gulp.src(paths.liquidSrc)
.pipe(twig({
data: yamlData
}))
.pipe(replaceExtension('.html'))
.pipe(htmlmin({collapseWhitespace: true}))
.pipe(gulp.dest(paths.dist));
});
gulp.task('build:other', function () {
return gulp.src([
paths.src + 'CNAME',
paths.src + 'manifest.json'
])
.pipe(gulp.dest(paths.dist));
});
gulp.task('build:assets', function () {
return gulp.src([
paths.src + 'assets/**/*.*',
'!' + paths.src + 'assets/**/*.scss'
])
.pipe(gulp.dest(paths.dist + 'assets/'));
});
gulp.task('build:styles', function () {
return gulp.src(paths.sassSrc)
.pipe(sass())
.pipe(replaceExtension('.css'))
.pipe(cleanCSS({compatibility: 'ie11'}))
.pipe(gulp.dest(paths.dist + 'assets/'));
});
gulp.task('build', ['build:html', 'build:assets', 'build:other', 'build:styles']);
gulp.task('watch', ['build'], function () {
gulp.watch(paths.allSrc, ['build']);
});
gulp.task('deploy', ['build'], function () {
return gulp.src(paths.allDist)
.pipe(deploy());
});