-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (74 loc) · 2 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
var gulp = require('gulp');
var bs = require('browser-sync').create();
var zip = require('gulp-zip');
var less = require('gulp-less');
var proxy = require('http-proxy-middleware');
var clean = require('gulp-clean');
var sequence = require('run-sequence');
gulp.task('server', function() {
var files = [
'page/**/*.html',
'css/**/*.less',
'js/**/*.js'
];
bs.watch(files, function (event, file) {
if (event === "change") {
bs.reload();
}
});
gulp.watch('css/**/*.less', ['less']);
// 提供过滤器以被重新加载阻止不需要的文件
gulp.task('less', function () {
return gulp.src('css/**/*.less')
.pipe(less())
.pipe(gulp.dest('css'))
// .pipe(bs.stream({match: "**/*.css"}));
});
gulp.start('less');
bs.init({
server: {
baseDir: "./",
middleware: proxy("/api", {
// target: 'http://192.168.129.192:8081',
// target: 'http://prepinsuranceapixxb.bz-ins.com/',
target: 'http://wxtest.bz-ins.com/',
changeOrigin: true,
pathRewrite: {
'^/api': '/api'
}
})
},
open: "external"
});
});
var files = [
'page/**/*',
'css/**/*.css',
'images/**/*',
'img/**/*',
'plugins/**/*',
'index.html'
];
gulp.task("copyFile", function () {
return gulp.src(files, {base: '.'})
.pipe(gulp.dest("dist"))
})
//清空dist目录
gulp.task("clean", function () {
console.log('清空 dist 目录下的资源')
return gulp.src('dist/*', {
read: false
})
.pipe(clean({
force: true
}));
})
//生成生产war包
gulp.task("package", function () {
gulp.src(['dist/**']).pipe(zip('dist.zip')).pipe(gulp.dest('dist'));
console.info('package ok!');
});
gulp.task('copy', function (callback) {
sequence('clean', 'copyFile',callback)
})
gulp.task('default', ["server"]);