forked from cozuya/one-night-werewolf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.babel.js
77 lines (70 loc) · 1.9 KB
/
gulpfile.babel.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
71
72
73
74
75
76
77
'use strict';
let gulp = require('gulp'),
livereload = require('gulp-livereload'),
plumber = require('gulp-plumber'),
browserify = require('browserify'),
babelify = require('babelify'),
through2 = require('through2'),
transform = require('vinyl-transform'),
rename = require('gulp-rename'),
opn = require('opn'),
sass = require('gulp-sass'),
wait = require('gulp-wait'),
sourcemaps = require('gulp-sourcemaps'),
notify = require('gulp-notify'),
nodemon = require('gulp-nodemon'),
exec = require('child_process').exec;
gulp.task('default', ['watch']);
gulp.task('watch', () => {
// opn('http://localhost:8080/');
livereload.listen();
gulp.watch('./src/scss/*.scss', ['styles']);
gulp.watch('./src/frontend-scripts/**/*.js*', ['scripts', 'lint']);
gulp.watch('./routes/*.js', ['reload']);
});
gulp.task('lint', () => {
// gulp.src(['./src/frontend-scripts/*.js*'])
// .pipe(jshint())
// .pipe(jshint.reporter('jshint-stylish'));
});
gulp.task('styles', () => {
return gulp.src('./src/scss/style.scss')
.pipe(sourcemaps.init())
.pipe(sass({outputStyle: 'compressed'}).on('error', () => {
notify('sass error');
return sass.logError;
}))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./public/styles/'))
.pipe(wait(1000))
.pipe(livereload());
});
gulp.task('scripts', () => {
gulp.src('./src/frontend-scripts/game-app.js')
.pipe(through2.obj((file, enc, next) => {
browserify(file.path, {debug: true})
.transform(babelify)
.bundle((err, res) => {
if (err) {
notify(err);
return next(err);
}
file.contents = res;
next(null, file);
});
}))
.on('error', function (error) {
notify(error.stack);
console.log(error.stack);
this.emit('end');
})
.pipe(rename('bundle.js'))
.pipe(gulp.dest('./public/scripts'))
.pipe(wait(500))
.pipe(livereload());
});
gulp.task('reload', () => {
gulp.src('')
.pipe(wait(4500))
.pipe(livereload());
});