-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
53 lines (47 loc) · 1.31 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
var growl = require('growl')
var serve = require('gulp-live-serve')
var livereload = require('gulp-livereload')
var webpack = require('webpack')
var gutil = require('gulp-util')
var gulp = require('gulp')
var path = require('path')
var config = require('./webpack.config')
// no conflict
var myConfig = Object.assign({}, config, {
devtool: 'sourcemap',
debug: true
})
var paths = {
// file list for webpack build
scripts: ['lib/**/*.js', 'example/*.js'],
// file list for reload
asserts: ['example/resources/*', 'example/*.html']
}
gulp.task('default', ['build-dev'])
gulp.task('build-dev', ['webpack:build-dev', 'serve'], function () {
livereload.listen({
start: true
})
// build js files on change
gulp.watch(paths.scripts, ['webpack:build-dev'])
var watcher = gulp.watch(paths.asserts)
watcher.on('change', function (e) {
livereload.changed(e.path)
growl(path.basename(e.path))
})
})
// static server
gulp.task('serve', serve({
root: __dirname,
middlewares: []
}))
gulp.task('webpack:build-dev', function (callback) {
var devCompiler = webpack(myConfig)
devCompiler.run(function (err, stats) {
if (err) throw new gutil.pluginError('webpack:build-dev', err) //eslint-disable-line
gutil.log('[webpack:build-dev]', stats.toString({
colors: true
}))
callback()
})
})