-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
56 lines (44 loc) · 1.2 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
var gulp = require('gulp');
// for javascript
var browserify = require('browserify');
var babelify = require('babelify');
var source = require('vinyl-source-stream');
// for css
var less = require('gulp-less');
var autoprefixer = require('gulp-autoprefixer');
// for server
var browserSync = require('browser-sync');
var reload = browserSync.reload;
gulp.task('js', () => {
return browserify({entries: ['./js/main.js']})
.transform(babelify, {presets: ['es2015']})
.bundle()
.on('error', onError)
.pipe(source('./main.js'))
.pipe(gulp.dest('.'))
.pipe(reload({stream: true}));
});
gulp.task('less', () => {
return gulp.src('./css/main.less')
.pipe(less({paths: [ './css' ]}))
.on('error', onError)
.pipe(autoprefixer({
browsers: ['last 2 versions'],
cascade: false
}))
.pipe(gulp.dest('./'))
.pipe(reload({stream: true}));
});
function onError(err) {
console.log(err.message);
this.emit('end');
}
gulp.task('serve', ['js', 'less'], () => {
browserSync({server: {baseDir: '.'}});
gulp.watch('./index.html').on('change', () =>{
console.log('wtf');
reload()
});
gulp.watch('./css/**/*.less', ['less']);
gulp.watch(['./js/**/*.js','./data.yaml'], ['js']);
});