-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
57 lines (49 loc) · 1.36 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
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var browserify = require('browserify');
var watchify = require('watchify');
var less = require('gulp-less');
var refresh = require('gulp-livereload');
var lr = require('tiny-lr');
var server = lr();
gulp.task('js-build', function () {
return browserify('./src/client.js')
.transform({
global: true,
}, 'uglifyify')
.bundle()
.pipe(source('index.js'))
.pipe(gulp.dest('./static'))
});
gulp.task('js-watch', function () {
var bundler = watchify('./src/client.js')
var rebundle = function () {
return bundler.bundle({ debug: true })
.pipe(source('index.js'))
.pipe(gulp.dest('./static'))
.pipe(refresh(server));
}
bundler.on('update', rebundle);
return rebundle();
});
gulp.task('css-watch', function () {
return gulp.src('./src/index.less')
.pipe(less())
.pipe(gulp.dest('static'))
.pipe(refresh(server));
});
gulp.task('css-build', function () {
return gulp.src('./src/index.less')
.pipe(less({
compress: true
}))
.pipe(gulp.dest('static'))
});
gulp.task('lr-server', function (cb) {
server.listen(35729, cb);
});
gulp.task('watch', function () {
gulp.watch('./src/**/*.less', ['css-watch']);
});
gulp.task('develop', ['lr-server', 'js-watch', 'css-watch', 'watch']);
gulp.task('default', ['js-build', 'css-build']);