-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
53 lines (47 loc) · 1.54 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
/*
* Gulp Plugins
*/
var gulp = require('gulp'),
Promise = require('promise'),
connect = require('gulp-connect'),
connectSSI = require('gulp-connect-ssi');
/*
* Setting Pathsstella
*/
var paths = {
demo : 'demo/'
}
/* ---------------------------------------------------
* Task Gulp Connect [搭建一个localhost:8080 的服务器]
* https://github.com/avevlad/gulp-connect
*/
gulp.task('connect', function() {
return new Promise(function (resolve, reject) {
connect.server({
root: paths.demo,
livereload: true,
middleware: function(){
return [connectSSI({
baseDir: __dirname + '/',
ext: '.html',
domain: 'http://localhost:8080/',
method: 'readOnLineIfNotExist' // readOnLine|readLocal|readOnLineIfNotExist|downloadIfNotExist
})];
}
});
});
});
gulp.task('reload-html', function () {
return gulp.src([paths.demo + '**/*.htm',paths.demo + '**/*.html'])
.pipe(connect.reload());
});
/* ---------------------------------------------------
* Task Watch [CSS/JS 变更自动主让页面刷新]
* https://github.com/floatdrop/gulp-watch
*/
gulp.task('watch-file', function () {
// return gulp.watch(paths.demo+'css/**/*.css', gulp.parallel('reload-html'));
return gulp.watch([paths.demo + '**/*.html',paths.demo + '**/*.htm', paths.demo + '**/*.css'], gulp.parallel('reload-html'));
});
// gulp 4.0 改写
gulp.task('watch-demo',gulp.parallel('connect','watch-file')); //专题文件更新自动 F5