-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
67 lines (55 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
67
'use strict';
var browserSync = require('browser-sync').create();
var browserify = require('browserify');
var ghPages = require('gulp-gh-pages');
var gulp = require('gulp');
var del = require('delete');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
gulp.task('browserify', function () {
var b = browserify({
entries: './src/app.js',
debug: true,
// Tell browserify that Handlebars is loaded already
external: 'Handlebars'
});
// ignore the internal handlebars require
b.ignore('handlebars');
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(gulp.dest('./_gh_pages/'))
.pipe(browserSync.stream());
});
gulp.task('cleanPublish', function(cb) {
del('./.publish', {force: true}, cb);
});
gulp.task('cleanDest', function(cb) {
del('./_gh_pages', {force: true}, cb);
});
gulp.task('clean', gulp.parallel(['cleanPublish', 'cleanDest']));
gulp.task('copy', function() {
return gulp.src('./src/index.html')
.pipe(gulp.dest('_gh_pages'))
.pipe(browserSync.stream());
});
gulp.task('serve', function(cb) {
browserSync.init({
port: 8080,
startPath: 'index.html',
server: {
baseDir: '_gh_pages'
}
}, cb);
});
gulp.task('watch', function() {
gulp.watch(['./src/**/*'], gulp.series('build'));
});
gulp.task('push', function() {
return gulp.src('_gh_pages/**/*')
.pipe(ghPages());
});
gulp.task('deploy', gulp.series(['push', 'cleanPublish']));
gulp.task('build', gulp.series('clean', gulp.parallel(['browserify', 'copy'])));
gulp.task('dev', gulp.series('build', gulp.parallel('serve', 'watch')));
gulp.task('default', gulp.series('build'));