-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
58 lines (46 loc) · 1.21 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
var gulp = require('gulp');
var sass = require('gulp-sass');
var rename = require('gulp-rename');
var babel = require('babelify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var watchify = require('watchify');
gulp.task('styles', function () {
gulp
.src('index.scss')
.pipe(sass())
.pipe(rename('app.css'))
.pipe(gulp.dest('public'));
})
gulp.task('assets', function () {
gulp
.src('assets/*')
.pipe(gulp.dest('public'));
})
function compile(watch) {
var bundle = browserify('./src/index.js', {debug: true});
if (watch) {
bundle = watchify(bundle);
bundle.on('update', function () {
console.log('--> Bundling...');
rebundle();
});
}
function rebundle(){
bundle
.transform(babel, { presets: [ 'es2015' ], plugins: ['syntax-async-functions', 'transform-regenerator']})
.bundle()
.on('error', function (err) { console.log(err); this.emit('end')})
.pipe(source('index.js'))
.pipe(rename('app.js'))
.pipe(gulp.dest('public'));
}
rebundle();
}
gulp.task('build', function () {
return compile();
});
gulp.task('watch', function () {
return compile(true);
});
gulp.task('default', ['styles', 'assets', 'build']);