-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
43 lines (39 loc) · 1.12 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
var gulp = require('gulp');
//var eslint = require('gulp-eslint');
var babel = require('gulp-babel');
//var rename = require('gulp-rename');
//var plumber = require('gulp-plumber');
var connect = require('gulp-connect');
var path = require('path');
var projpath = process.env.projpath;
gulp.task('server', function() {
connect.server({
root:projpath
});
})
gulp.task('lint', function() {
gulp
.src(path.join(projpath, './es6.js'))
.pipe(eslint({ //错误检测
"rules": {
"semi": [1, "always"], //分号
"quotes": [1, "single"] //单引号
}
}))
.pipe(eslint.format()) //规范检测
console.log(path.join(projpath, './es6.js'));
})
gulp.task('babel', function() {
gulp
.src(path.join(projpath, './es6.js'))
.pipe(plumber())
.pipe(babel({
presets: ['es2015']
}))
.pipe(rename('index.js'))
.pipe(gulp.dest(path.join(projpath, './')))
})
gulp.task('watch', function() {
gulp.watch('./es6.js', ['babel', 'lint']);
})
gulp.task('default', ['babel', 'lint', 'watch']);