-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
52 lines (44 loc) · 1.28 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
const gulp = require('gulp');
const webpack = require('webpack');
const WebpackDevServer = require('webpack-dev-server');
const gutil = require('gulp-util');
const webpackConf = require('./webpack.config');
const jshint = require('gulp-jshint');
function webpackDevServer ()
{
let compiler = webpack(webpackConf);
new WebpackDevServer(compiler,
{
stats: {
colors: true
}
}).listen(9001, 'localhost', function (err)
{
if (err) throw new gutil.PluginError('webpack-dev-server', err);
gutil.log('[webpack-dev-server]', 'http://localhost:9001/index.html');
});
}
function lint (files)
{
return gulp.src(files)
.pipe(jshint({lookup: true}))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail')); // fails task if error
}
function lintSrc ()
{
return lint('src/*.js');
}
function lintMain ()
{
return lint('static/main.js');
}
function build (done)
{
webpack(webpackConf).run(done);
}
gulp.task('develop:lint', gulp.series(lintSrc, lintMain));
gulp.task('develop:build', gulp.series('develop:lint', build));
gulp.task('develop:server', webpackDevServer);
gulp.task('develop', gulp.series('develop:lint', build, 'develop:server'));
gulp.task('default', gulp.series('develop'));