-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (59 loc) · 1.71 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
const gulp = require('gulp');
const uglify = require('gulp-uglify');
const babel = require('gulp-babel');
const replace = require('gulp-replace');
const nodemon = require('gulp-nodemon');
const cleanCSS = require('gulp-clean-css');
const gzip = require('gulp-gzip');
const spawn = require('child_process').spawn;
const exec = require('child_process').exec;
gulp.task('server', function() {
return gulp.src(['src/index.js'])
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify())
.pipe(replace("/\\n/", "wellIsntthisunique"))
.pipe(replace(/\\t|\\r|\\n/g, '')) // remove whitespace from template strings
.pipe(replace("wellIsntthisunique", "/\\n/"))
.pipe(replace(/function\(([a-z, ]+)\)/gi, '($1)=>'))
.pipe(gulp.dest('dist'))
.pipe(gulp.dest('tests'));
})
gulp.task('client', () => {
return gulp.src(['src/client.js'])
.pipe(babel({
presets: ['es2015']
}))
.pipe(uglify())
.pipe(gzip())
.pipe(gulp.dest('dist'));
})
gulp.task('css', () => {
return gulp.src('src/app.css')
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gzip())
.pipe(gulp.dest('dist'));
})
gulp.task('size', () => {
return spawn('./bin/size.sh', [], {stdio: "inherit"})
})
gulp.task('gzip-index', ()=> {
let build = exec('node build.js', [], {stdio: "inherit"})
build.on('error', function(err) {
console.log(err)
})
return build
})
gulp.task('build', ['server', 'client', 'css'], function() {
exec('node build.js', [], {stdio: "inherit"})
});
gulp.task('watch', ['build'], function () {
var stream = nodemon({
script: 'dist/index.js',
watch: 'src',
ext: 'js css',
tasks: ['build'],
})
return stream
})