-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
50 lines (49 loc) · 1.1 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
const { src, dest } = require("gulp");
const babel = require("gulp-babel");
const uglify = require("gulp-uglify");
const rename = require("gulp-rename");
const header = require("gulp-header");
var pkg = require("./package.json");
var banner = [
"/**",
" * <%= pkg.name %> - <%= pkg.description %>",
" * @version v<%= pkg.version %>",
" * @author <%= pkg.author %>",
" * @buildAt <%= buildTime %>",
" */",
""
].join("\n");
exports.default = function() {
return (
src("lib/converter.js")
// es6 => es5
.pipe(babel())
// 增加生成时间
.pipe(
header(banner, {
pkg,
buildTime: new Date().toISOString()
})
)
.pipe(dest("lib/"))
// 压缩
.pipe(
uglify({
compress: {
negate_iife: false,
drop_console: true
}
})
)
// 增加生成时间
.pipe(
header(banner, {
pkg,
buildTime: new Date().toISOString()
})
)
// 重命名
.pipe(rename({ extname: ".min.js" }))
.pipe(dest("lib/"))
);
};