-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
120 lines (106 loc) · 3.05 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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var autoprefixer = require('gulp-autoprefixer');
var cp = require('child_process');
var pug = require('gulp-pug');
var ghpages = require('gh-pages');
var htmlmin = require('gulp-htmlmin');
var csso = require('gulp-csso');
var pump = require('pump');
var uglify = require('gulp-uglify');
var imagemin = require('gulp-imagemin');
var sitemap = require('gulp-sitemap');
path = require('path');
const BROWSERS = [
'ie >= 10',
'ie_mob >= 10',
'ff >= 30',
'chrome >= 34',
'safari >= 7',
'opera >= 23',
'ios >= 7',
'android >= 4.4',
'bb >= 10'
];
var jekyll = process.platform === 'win32' ? 'jekyll.bat' : 'jekyll';
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn( jekyll , ['build'], {stdio: 'inherit'})
.on('close', done);
});
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
gulp.task('browser-sync', ['sass', 'jekyll-build'], function() {
browserSync({
server: {
baseDir: '_site'
},
notify: true
});
});
gulp.task('sass', function () {
return gulp.src('assets/css/main.scss')
.pipe(sass({
includePaths: ['css'],
onError: browserSync.notify
}))
.pipe(autoprefixer({browsers: BROWSERS}))
.pipe(csso())
.pipe(gulp.dest('_site/assets/css'))
.pipe(browserSync.reload({stream:true}))
.pipe(gulp.dest('assets/css'));
});
gulp.task('uglify', function (cb) {
pump([
gulp.src('assets/js/*.js'),
uglify(),
gulp.dest('_site/assets/js')
],
cb
);
});
gulp.task('pug', function(){
return gulp.src('_pugfiles/*.pug')
.pipe(pug())
.pipe(gulp.dest('_includes'));
});
gulp.task('htmlmin', function () {
return gulp.src('_site/*.html')
.pipe(htmlmin({
collapseWhitespace: true,
removeComments: true
}))
.pipe(gulp.dest('_site'))
});
gulp.task('imagemin', function(){
return gulp.src('assets/images/pre/**')
.pipe(imagemin({
interlaced: true,
progressive: true,
optimizationLevel: 5
}))
.pipe(gulp.dest('assets/images'))
})
gulp.task('watch', function () {
gulp.watch('assets/css/**', ['sass']);
gulp.watch('assets/js/**', ['uglify']);
gulp.watch(['*.html', '*.yml', '_layouts/*.html', '_includes/*', '_data/*', '_assets/css/**'], ['jekyll-rebuild']);
gulp.watch('_pugfiles/*.pug', ['pug']);
gulp.watch('_site/*.html', ['htmlmin']);
});
gulp.task('deploy', function(cb) {
gulp.src('_site/*.html', {
read: false
})
.pipe(sitemap({
siteUrl: 'http://www.dickwyn.xyz'
}))
.pipe(gulp.dest('_site'));
ghpages.publish(path.join(process.cwd(), '_site'), cb);
});
gulp.task('default', ['browser-sync', 'watch']);