-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
46 lines (40 loc) · 1.31 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
var gulp = require('gulp'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
buffer = require('vinyl-buffer'),
jshint = require('gulp-jshint'),
cp = require('child_process').exec,
uglify = require('gulp-uglify'),
bs = require('browser-sync').create();
var src = './assets',
dest = './_site/assets';
// Task for building blog when something changed:
gulp.task('jekyll',['js'], function(){
return cp('bundler exec jekyll build --watch --future',
function(err,stdout,stderr){
console.log(err);
console.log(stdout);
console.log(stderr);
});
});
// Task for serving blog with Browsersync
gulp.task('serve', ['js'], function () {
bs.init({server: {baseDir: '_site/'}, port: 4000});
// Reloads page when some of the already built files changed:
gulp.watch('_site/**/*.*').on('change', bs.reload);
});
gulp.task('js', function(){
return browserify({
entries: './components/main.js',
debug: true
}).bundle()
.pipe(source('main.min.js'))
.pipe(jshint())
// .pipe(buffer())
// .pipe(uglify())
.pipe(gulp.dest(src + '/js'));
});
gulp.task('watch',function(){
gulp.watch('./components/*.js', ['js']);
});
gulp.task('default', ['js','watch','serve']);