-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
54 lines (47 loc) · 1.31 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
54
var gulp = require('gulp'),
del = require('del'),
path = require('path'),
url = require('url'),
connect = require('gulp-connect'),
open = require('gulp-open'),
proxy = require('proxy-middleware');
var appConfig = {
node: 'node_modules',
app: 'app'
};
// 启动web服务器
// -------------------------------
var proxyOptions = url.parse('http://localhost:3000');
proxyOptions.route = '/api';
gulp.task('connect:dev', function() {
connect.server({
root: [appConfig.app],
port: 3002,
livereload: true,
middleware: function(connect, opt) {
return [
proxy(proxyOptions),
connect().use(
'/pics',
connect.static('./pics')
),
connect().use(
'/videos',
connect.static('./videos')
)
]
}
});
});
// 打开浏览器
// -------------------------------
gulp.task('open', function() {
return gulp.src(__filename).pipe(open({
uri: 'http://localhost:3002'
}));
});
// 运行开发环境
// -------------------------------
gulp.task('default', ['connect:dev', 'open'], function() {
console.log('Started App!');
});