Skip to content

Commit c9f3961

Browse files
author
zhangbo
committed
gulp入口文件
1 parent 57b58e7 commit c9f3961

File tree

3 files changed

+23
-20
lines changed

3 files changed

+23
-20
lines changed
File renamed without changes.

gulpfile.js

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
var gulp = require('gulp');
2-
var connect = require('gulp-connect');
2+
var browserSync = require('browser-sync').create();
33

4-
gulp.task('connect' , function(){
5-
connect.server({
6-
port : 3001,
7-
livereload : true
4+
gulp.paths = {
5+
demo : 'demo'
6+
}
7+
8+
gulp.task('browser-sync', function() {
9+
10+
browserSync.init({
11+
server: {
12+
baseDir : gulp.paths.demo,
13+
index : 'index.html',
14+
routes: {
15+
"/bower_components": "bower_components",
16+
}
17+
},
18+
startPath: '/',
19+
files : gulp.paths.demo + '/*.*',
20+
//port : 3001
821
});
9-
})
1022

11-
gulp.task('html' , function(){
12-
gulp.src('./demo/*.html')
13-
.pipe(connect.reload);
14-
})
23+
gulp.watch( gulp.paths.demo + "/*.*").on('change', browserSync.reload);
24+
});
1525

16-
gulp.task('js' , function(){
17-
gulp.src('./demo/*.js')
18-
.pipe(connect.reload);
19-
})
26+
gulp.task('serve' , ['browser-sync']);
2027

21-
gulp.task('watch' , function(){
22-
gulp.watch(['./demo/*.html'],['html']);
23-
gulp.watch(['./demo/*.js'],['js']);
24-
})
2528

26-
gulp.task('serve' , ['connect' , 'watch'])

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"devDependencies": {
2424
"gulp": "~3.9.0",
25-
"gulp-connect": "~2.2.0"
25+
"gulp-connect": "~2.2.0",
26+
"browser-sync": "~2.8.1"
2627
}
2728
}

0 commit comments

Comments
 (0)