-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
54 lines (48 loc) · 1.21 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
var gulp = require('gulp');
var livereload = require('gulp-livereload');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var browserify = require('browserify');
/**
* @define {object} paths for building
*/
var settings = {
build: './dist',
source: './src'
};
var liveTestSettings = {
build: './test/live/public',
source: './test/live'
};
/*
* Bundler
* --------------------------------------------------
*/
var bundler = watchify(browserify(liveTestSettings.source + '/index.js'));
/*
* JS
* --------------------------------------------------
*/
gulp.task('live-test', function(){
return bundler.bundle()
.on('error', function(err){ console.log(err.message); this.emit('end');})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(gulp.dest(liveTestSettings.build + '/js'))
.pipe(livereload());
});
/*
* Watch
* --------------------------------------------------
*/
gulp.task('watch', function() {
livereload.listen();
gulp.watch(['./*.js', './test/live/*.js'], ['live-test']);
});
/*
* Default
* --------------------------------------------------
*/
gulp.task('dev', ['live-test']);
gulp.task('default', ['watch', 'dev']);