-
Notifications
You must be signed in to change notification settings - Fork 264
/
gulpfile.js
99 lines (80 loc) · 2.39 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
'use strict';
var fs = require('fs');
var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
$.del = require('del');
$.open = require('open');
$.exec = require('sync-exec');
gulp.task('build', ['render', 'styles'], function() {
$.del.sync('build');
gulp.src('src/index.html')
.pipe($.if('*.css', $.minifyCss()))
.pipe($.if('*.js', $.uglify()))
.pipe($.useref())
.pipe(gulp.dest('build/'))
.on('end', function() {
// inline all the styles
var file = fs.readFileSync('build/index.html').toString();
file = file.replace(/<link.+href="(.+\.css)">/gm, function(m, file) {
return '<style>' + fs.readFileSync('build/' + file) + '/*# sourceMappingURL=style.css.map */</style>';
});
fs.writeFileSync('build/index.html', file, 'utf8');
});
// copy all the necessary files
gulp.src([
'src/404.html',
'src/favicon.png',
'src/apple-touch-icon.png',
'src/CNAME'
], { dot:true }).pipe(gulp.dest('build/'));
gulp.src('src/css/style.css.map').pipe(gulp.dest('build/css'));
gulp.src('src/img/*').pipe(gulp.dest('build/img'));
});
gulp.task('watch', function() {
gulp.watch(['src/js/*.js', 'gulpfile.js', './lib/*.js', 'new_feature.js'], ['reload:js', 'lint:js']);
gulp.watch(['src/template.html', 'posts/*.md'], ['render']);
gulp.watch('src/sass/*', ['styles']);
});
gulp.task('styles', function() {
$.exec('compass compile .');
});
gulp.task('serve', ['render', 'styles'], function() {
$.connect.server({ root: 'src', livereload: true });
$.open('http://localhost:8080');
});
gulp.task('new', function() {
require('./new_feature');
if ($.connect.reload) {
gulp.src('src/index.html')
.pipe($.connect.reload());
}
});
gulp.task('render', function() {
require('./lib')('render');
if ($.connect.reload) {
gulp.src('src/index.html')
.pipe($.connect.reload());
}
});
gulp.task('checkurls', function() {
require('./lib')('checkurls');
});
gulp.task('lint:js', function() {
return gulp.src(['src/js/*.js', 'gulpfile.js', './lib/*.js', 'new_feature.js'])
.pipe($.jscs('./.jscsrc'))
.pipe($.jshint('./.jshintrc'))
.pipe($.jshint.reporter('jshint-stylish'));
});
gulp.task('reload:js', function() {
if ($.connect.reload) {
gulp.src('src/js/*.js')
.pipe($.connect.reload());
}
});
gulp.task('dev', [
'styles',
'render',
'watch',
'serve'
]);
gulp.task('default', ['dev']);