-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
46 lines (40 loc) · 1.08 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
var path = require('path')
var growl = require('growl')
var serve = require('gulp-live-serve')
var livereload = require('gulp-livereload')
var webpack = require('webpack')
var gulpWebpack = require('gulp-webpack')
var gulp = require('gulp')
var webpackConfig = require('./webpack.config')
// example index
var exampleFiles = ['example/*.css', 'example/bundle.js', 'example/index.html']
var main = './example/index.js'
var myConfig = Object.assign({}, webpackConfig, {
entry: main,
output: {
filename: 'bundle.js',
},
debug: true,
devtool: 'cheap-module-eval-source-map',
watch: true
})
gulp.task('build', ['serve'], function () {
livereload.listen({
start: true
})
// reload on file change
var watcher = gulp.watch(exampleFiles)
watcher.on('change', function (e) {
livereload.changed(e.path)
growl(path.basename(e.path))
})
return gulp.src('example/index.js')
.pipe(gulpWebpack(myConfig, webpack))
.pipe(gulp.dest('example'))
})
// static server
gulp.task('serve', serve({
root: __dirname,
middlewares: []
}))
gulp.task('default', ['build'])