-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
42 lines (39 loc) · 1.14 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
/**
* Created by Administrator on 2017/2/9.
*/
var gulp = require('gulp'),
connect = require('gulp-connect'),
babel = require("gulp-babel"),
sass = require('gulp-ruby-sass');
gulp.task('connect', function() {
connect.server({
port: 3001, //端口号,可不写,默认8000
root: './dist', //当前项目主目录
livereload: true //自动刷新
});
});
gulp.task('html', function() {
gulp.src('./src/*.html')
.pipe(gulp.dest('./dist'))
.pipe(connect.reload());
});
gulp.task('sass', function() {
sass('./src/sass/*.scss')
.on('error', sass.logError)
.pipe(gulp.dest('./dist/css'))
.pipe(connect.reload());
});
gulp.task('js', function() {
gulp.src('./src/js/*.js')
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest('./dist/js'))
.pipe(connect.reload());
});
gulp.task('watch', function() {
gulp.watch('src/sass/*.scss', ['sass']); //监控scss文件
gulp.watch(['src/*.html'], ['html']); //监控html文件
gulp.watch(['src/js/*.js'], ['js']); //监控js文件
});
gulp.task('default', ['connect', 'watch']);