-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
executable file
·53 lines (46 loc) · 1.37 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
let gulp = require('gulp'),
less = require('gulp-less'),
browserSync = require('browser-sync'),
del = require('del');
babel = require("gulp-babel");
function swallowError (error) {
console.log(error.toString())
this.emit('end')
}
gulp.task('clean', function() {
return del.sync('build');
});
gulp.task('html', function(){
return gulp.src('src/*.html')
.pipe(gulp.dest('build/'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('js', function(){
return gulp.src('src/js/**/*.js')
.pipe(babel())
.on('error', swallowError)
.pipe(gulp.dest('build/js'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('less', function(){
return gulp.src('src/less/*.less')
.pipe(less())
.pipe(gulp.dest('build/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('assets', function(){
return gulp.src('src/assets/*.*')
.pipe(gulp.dest('build/assets'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('watch', ['clean', 'html', 'less','js', 'assets'], function() {
browserSync({
server: {
baseDir: './build/'
}
});
gulp.watch('src/less/**/*.less', ['less']);
gulp.watch('src/**/*.html', ['html']);
gulp.watch('src/js/**/*.js', ['js']);
});
gulp.task('default', ['watch']);