-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
47 lines (40 loc) · 1.36 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
var gulp = require('gulp');
var mocha = require('gulp-mocha');
let webpack = require('webpack');
var webserver = require('gulp-webserver');
let WebpackDevServer = require('webpack-dev-server');
let wpConf = require('./webpack.config.js');
var gutil = require('gulp-util');
gulp.task('test', function() {
gulp.src('./tests/**/*.js').pipe(mocha()).on('error', function(err) {
console.log('Error:' + err);
this.emit('end');
});
});
gulp.task('watch', function() {
gulp.watch('./**/*.+(js|html)', ['test']);
gulp.watch('./tests/**/*.js', ['test']);
});
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
port: 8080,
livereload: true,
directoryListing: false,
open: 'http://localhost:8080/'
}));
});
gulp.task('serve', function(callback) {
// Start a webpack-dev-server
var compiler = webpack(wpConf);
new WebpackDevServer(compiler, {
// server and middleware options
}).listen(8080, 'localhost', function(err) {
if (err) throw new gutil.PluginError('webpack-dev-server', err);
// Server listening
gutil.log('[webpack-dev-server]', 'http://localhost:8080/webpack-dev-server/index.html');
// keep the server alive or continue?
// callback()
});
});
gulp.task('default', ['watch', 'webserver', 'test']);