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