-
Notifications
You must be signed in to change notification settings - Fork 9
/
gulpfile.js
51 lines (43 loc) · 1.06 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
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 = watchify(browserify('./src/index.js'))
function rebundle() {
bundle
.transform(babel)
.bundle()
.on('error', function (err) { console.log(err); this.emit('end') })
.pipe(source('index.js'))
.pipe(rename('app.js'))
.pipe(gulp.dest('public'));
}
if (watch) {
bundle.on('update', function () {
console.log('---> Bundling...');
rebundle();
})
}
rebundle();
}
gulp.task('build', function () {
return compile();
});
gulp.task('watch', function () { return compile(true); });
gulp.task('default', ['styles', 'assets', 'build']);