Repository navigation
Expand file tree
/
Copy pathgulpfile.js
More file actions
106 lines (76 loc) · 2.39 KB
/
Copy pathgulpfile.js
File metadata and controls
106 lines (76 loc) · 2.39 KB
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
var gulp = require('gulp')
var browserSync = require('browser-sync')
var cp = require('child_process')
var browserify = require('gulp-browserify')
var unassert = require('gulp-unassert');
var rename = require('gulp-rename')
// var connect = require('gulp-connect-php')
// gulp.task('connect', function() {
// browserSync({
// server: {
// baseDir: '/'
// }
// });
// });
// gulp.task('connect', function() {
// connect.server({}, function() {
// browserSync({
// proxy: '127.0.0.1:8000'
// })
// })
// })
// gulp.task('browser-reload', browserSync.reload);
var messages = {
jekyllBuild: '<span style="color: grey">Running:</span> $ jekyll build'
};
/**
* Build the Jekyll Site
*/
gulp.task('jekyll-build', function (done) {
browserSync.notify(messages.jekyllBuild);
return cp.spawn('jekyll', ['build'], {stdio: 'inherit', JEKYLL_ENV:'development'})
.on('close', done);
});
/**
* Rebuild Jekyll & do page reload
*/
gulp.task('jekyll-rebuild', ['jekyll-build'], function () {
browserSync.reload();
});
/**
* Wait for jekyll-build, then launch the Server
*/
gulp.task('browser-sync', ['scripts', 'jekyll-rebuild'], function() {
browserSync({
server: {
baseDir: '_site'
}
});
});
gulp.task('scripts', function() {
var stream = gulp.src('js/app.js')
.pipe(browserify({
insertGlobals: true,
debug: !gulp.env.production
}))
.pipe(unassert())
.pipe(rename('bundle.js'))
.pipe(gulp.dest('./js'));
stream.on('end', browserSync.reload);
});
// gulp.task('watch', function () {
// gulp.watch(['js/*.js', 'js/*/*.js'], ['scripts']);
// gulp.watch(['index.html', 'api.php'], ['browser-reload']);
// })
// gulp.task('default', ['connect', 'watch']);
gulp.task('watch', function () {
gulp.watch(['js/*.js', 'js/*/*.js'], ['scripts']);
gulp.watch(['index.html', '*/*.html', '*/*.md', 'en/**/*', '_layouts/*.html', '_includes/*.html', '_posts/*', '_data/*', '_config.yml', 'js/*.js', 'sitemap.xml',], ['jekyll-rebuild']);
});
/**
* Default task, running just `gulp` will compile the less,
* compile the jekyll site, launch BrowserSync & watch files.
*/
gulp.task('default', ['browser-sync', 'watch']);
// gulp.task('prod', ['browser-sync', 'production']);
gulp.task('build', ['scripts', 'jekyll-build']);