-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.js
105 lines (91 loc) · 2.37 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
// originally based on https://github.com/vanjacosic/run-wintersmith
//
// 'gulp watch' runs preview mode with a local server and refreshes the browser
// when Markdown or Jade files are modified. Requires Livereload for Chrome.
//
// 'gulp build' builds the site to the default folder.
// Include gulp
var gulp = require('gulp');
var gutil = require('gulp-util');
// Include plugins
var clean = require('gulp-rimraf');
var refresh = require('gulp-livereload');
var browserSync = require('browser-sync').create();
var reload = browserSync.reload;
var runWintersmith = require('run-wintersmith');
var cssnext = require('gulp-cssnext')
var iconify = require('gulp-iconify')
var lr = require('tiny-lr');
var server = lr();
//
// Directories
//
var BUILD_DIR = 'build';
var CONTENT_DIR = 'contents';
var TEMPLATES_DIR = 'templates';
//
// Helper task - Cleans everything in build dir
//
gulp.task('clean', function() {
return gulp.src(BUILD_DIR, { read: false }).pipe(clean());
});
//
// Build task
//
gulp.task('build', ['clean'], function(cb) {
// Tell Wintersmith to build
runWintersmith.build(function(){
// Log on successful build
gutil.log('Wintersmith has finished building!');
// Tell gulp task has finished
cb();
});
});
//
// CSS task
//
gulp.task("stylesheets", function() {
gulp.src("contents/css/src/index.css")
.pipe(cssnext({
compress: true
}))
.pipe(gulp.dest("contents/css"))
.pipe(browserSync.stream());
});
gulp.task('icons', function() {
iconify({
src: './contents/img/icons/*.svg'
});
});
//
// Preview task
//
gulp.task('preview', function() {
// Tell Wintersmith to run in preview mode
runWintersmith.preview();
});
gulp.task('browser-sync', function() {
browserSync.init({
proxy: "http://localhost:3000"
});
});
//
// Watch task
//
gulp.task('watch', ['stylesheets', 'preview', 'browser-sync'], function(){
function reportChange(e) {
gutil.log(gutil.template('File <%= file %> was <%= type %>, rebuilding...', {
file: gutil.colors.cyan(e.path),
type: e.type
}));
}
// Watch Jade template files
gulp.watch(TEMPLATES_DIR + '/**/*.jade')
.on('change', reportChange);
// Watch Markdown files
gulp.watch(CONTENT_DIR + '/**/*.md')
.on('change', reportChange);
// Watch CSS files
gulp.watch(CONTENT_DIR + '/css/src/**', ['stylesheets'])
.on('change', reportChange);
});