-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
57 lines (49 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
53
54
55
56
57
const gulp = require('gulp')
const traceur = require('gulp-traceur')
const plumber = require('gulp-plumber')
const webserver = require('gulp-webserver')
const clean = require('gulp-clean')
const argv = require('yargs').argv
const DEFAULT_SERVER_PORT = 8000
const OUTPUT_DIR = 'build'
const SOURCE_GLOB = 'src/**/*.js'
const SERVER_PORT = argv.port === undefined ? DEFAULT_SERVER_PORT : parseInt(argv.port)
const TRACEUR_OPTS = {
asyncFunctions: true,
modules: 'amd',
classes: 'parse',
generators: 'parse',
arrowFunctions: 'parse',
blockBinding: 'parse',
forOf: 'parse',
templateLiterals: 'parse',
arrayComprehension: true,
sourceMaps: 'inline'
}
gulp.task('default',['build', 'stream', 'serve'])
gulp.task('stream', () => {
gulp.watch(SOURCE_GLOB, ['build'])
})
gulp.task('build', () => {
gulp.src(SOURCE_GLOB)
.pipe(plumber({
handleError: (err) => {
console.log(err.toString())
this.emit('end')
}
}))
.pipe(traceur(TRACEUR_OPTS))
.pipe(gulp.dest(OUTPUT_DIR))
})
gulp.task('serve', () => {
gulp.src('.')
.pipe(webserver({
port: SERVER_PORT,
fallback: 'index.html',
livereload: false
}))
})
gulp.task('clean', () => {
gulp.src(OUTPUT_DIR)
.pipe(clean())
})