-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathgulpfile.js
More file actions
63 lines (53 loc) · 1.73 KB
/
Copy pathgulpfile.js
File metadata and controls
63 lines (53 loc) · 1.73 KB
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
'use strict';
// 在gulpfile中先载入gulp包,因为这个包提供了一些API
var gulp = require('gulp');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
const header = require('gulp-header');
const packageinfo = require('./package.json')
const banner = `/**
* ${packageinfo.description}
* 源码地址:${packageinfo.homepage}
* 版本信息:v${packageinfo.version}
* 编译日期:<%= date %>
* 版权所有:Copyright by 火星科技 木遥 http://marsgis.cn
*/
`;
//压缩混淆haoutil
gulp.task('build', done => {
let bannerData = { date: (new Date).format("yyyy-M-d HH:mm:ss") };
gulp.src([
"src/space.js",
"src/prototype.js",
"src/haoutil.*.js",
])
.pipe(concat('haoutil-src.js'))
.pipe(header(banner, bannerData))
.pipe(gulp.dest('dist/'))
.pipe(concat('haoutil.js'))
.pipe(uglify())
.pipe(header(banner, bannerData))
.pipe(gulp.dest('dist/'));
done();
});
Date.prototype.format = function (fmt) {
var o = {
"M+": this.getMonth() + 1, //月份
"d+": this.getDate(), //日
"h+": this.getHours() % 12 == 0 ? 12 : this.getHours() % 12, //小时
"H+": this.getHours(), //小时
"m+": this.getMinutes(), //分
"s+": this.getSeconds(), //秒
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
"S": this.getMilliseconds() //毫秒
};
if (/(y+)/.test(fmt)) {
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
}
for (var k in o) {
if (new RegExp("(" + k + ")").test(fmt)) {
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
}
}
return fmt;
};