-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
43 lines (33 loc) · 1008 Bytes
/
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
var gulp = require('gulp'),
connect = require('gulp-connect'),
browserify = require('browserify'),
source = require('vinyl-source-stream'),
path = require('path')
const appDir = path.join(__dirname, './app')
const tempDir = path.join(__dirname, './tmp')
function includeFile(file) {
return path.join(appDir, file)
}
gulp.task('connect', ['browserify', 'html'], function() {
connect.server({
root: [appDir, tempDir],
livereload: true
})
})
gulp.task('browserify', function() {
return browserify(includeFile('main.js'))
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest(tempDir))
.pipe(connect.reload())
})
gulp.task('html', function () {
gulp.src(includeFile('*.html'))
.pipe(connect.reload())
})
gulp.task('watch', ['browserify', 'html'], function () {
gulp.watch([includeFile('*.html')], ['html'])
gulp.watch([includeFile('*.js')], ['browserify'])
})
gulp.task('default', ['connect', 'watch'])
gulp.task('serve', ['connect'])