-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
70 lines (58 loc) · 1.46 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
const
commander = require('commander'),
connect = require('gulp-connect'),
elm = require('gulp-elm'),
gulp = require('gulp'),
gutil = require('gulp-util'),
plumber = require('gulp-plumber')
commander
.option('--output <path>', 'path to buit application', 'sample/app.js')
.option('--dir <path>','path to sources of blog', 'sample')
.option('--debug', '--debug option to elm-make')
.parse(process.argv)
const
output = commander.output,
dir = commander.dir,
debug = commander.debug || false
gutil.log('output = ' + output)
gutil.log('dir = ' + dir)
gutil.log('debug = ' + debug)
gulp.task('elm-init', elm.init)
gulp.task('build', ['elm-init'], () => {
return gulp.src('src/**/*.elm')
.pipe(plumber())
.pipe(elm.bundle(output, {debug: debug}))
.pipe(gulp.dest('.'))
})
gulp.task('server', [], () => {
connect.server({
port: 8000,
root: dir,
livereload: true,
debug: true
})
})
gulp.task('watch', [], () => {
gulp.watch('src/**/*.elm', ['build'])
const watchlist = [
'/index.html',
'/css/**/*.css',
'/config.json',
'/**/*.json',
'/**/*.markdown',
'/**/*.html'
].map((path) => {
return dir + path
})
watchlist.unshift(output)
gulp.watch(watchlist, (event) => {
gutil.log('LiveReload ' + event.path)
return gulp.src(event.path)
.pipe(plumber())
.pipe(connect.reload())
})
})
gulp.task('default', ['watch', 'server'])
gulp.on('error', (error) => {
gutil.log(error)
})