forked from menhal/menhal.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (40 loc) · 1.25 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
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps')
var browserSync = require("browser-sync");
var autoprefixer = require('gulp-autoprefixer');
var sass = require('gulp-sass')
//启动服务器
gulp.task('connect', function() {
browserSync({server: "./"})
});
gulp.task('html', function() {
gulp.src('./*.html')
.pipe(browserSync.stream());
});
gulp.task('css',function(){
gulp.src('./css/*.css')
.pipe(browserSync.stream({match: "**/*.css"}));
});
gulp.task('sass', function () {
gulp.src(['./sass/main.scss'])
.pipe(sourcemaps.init())
.pipe(sass({outputStyle:"expanded"}).on('error', sass.logError))
.pipe(autoprefixer("> 0.1%"))
.pipe(sourcemaps.write("."))
.pipe(gulp.dest('./css'));
});
gulp.task('watch', function () {
gulp.watch(['*.html'], ['html']);
gulp.watch(['css/*.css'], ['css']);
gulp.watch(['sass/**/*.scss'], ['sass']);
});
gulp.task('task', function() {
gulp.src('./*.html')
.pipe(browserSync.stream());
});
gulp.task('watch-task', function () {
gulp.watch(['tasks/**/*.html'], ['task']);
gulp.watch(['tasks/**/*.css'], ['task']);
gulp.watch(['tasks/**/*.js'], ['task']);
});
gulp.task('default', ['connect', 'watch', 'watch-task']);