-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (63 loc) · 1.94 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
var fs = require('fs');
var gulp = require('gulp');
var rename = require('gulp-rename');
var jshint = require('gulp-jshint');
var stylish = require('jshint-stylish');
var connect = require('gulp-connect');
var template = require('gulp-template');
var data = require('gulp-data');
var _ = require('lodash');
gulp.task('build', ['copy'], function(){
var slides = JSON.parse(fs.readFileSync('slides/list.json', {encoding: 'utf8'}));
var section = fs.readFileSync('templates/_section.html', {encoding: 'utf8'});
gulp.src(['templates/_index.html'])
.pipe(template({
slides: slides,
section: function(slide){
return _.template(section)({slide: slide});
}
}))
.pipe(rename('index.html'))
.pipe(gulp.dest('.'))
});
gulp.task('scripts', function(){
return gulp.src('js/slides/*.js')
.pipe(gulp.dest('.'));
});
gulp.task('copy', function(){
return gulp.src([ 'slides/**',
'bower_components/**',
'js/**',
'images/**',
'index.js',
'slides.js',
'styles.css',
'index.html'], {base: "."})
.pipe(gulp.dest('dist/'));
});
gulp.task('jshint', function(){
return gulp.src('js/**/*.js')
.pipe(jshint())
.pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('connect', function(){
connect.server({
root: './dist/',
port: 9000,
livereload: true
});
});
gulp.task('watch', function(){
//Live reload
var files = ['index.html','styles.css', 'slides/{,*/}*.{md,html}','js/**/*.js'];
gulp.watch(files, ['copy']);
gulp.watch(files, function(){
gulp.src(files)
.pipe(connect.reload());
});
gulp.watch('js/**/*.js', ['jshint', 'scripts', 'copy']);
gulp.watch(['templates/_index.html', 'templates/_section.html', 'slides/list.json'],
['build', 'copy']);
});
gulp.task('default', ['build', 'connect', 'watch']);
gulp.task('deploy', ['build', 'copy'])