-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
98 lines (93 loc) · 2.28 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
const { src, dest, series } = require('gulp');
const babel = require('gulp-babel');
let uglify = require('gulp-uglify-es').default;
var rename = require("gulp-rename");
const es6 = function (cb) {
src("./libs/index.js")
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry",//兼容,依赖core-js
"corejs": '3',
"targets": '> 1%,last 2 versions,not ie <= 11',
"loose": false
}
]
]
}))
.pipe(uglify({
compress: {
warnings: false,
drop_console: true, // 过滤 console
drop_debugger: true, // 过滤 debugger
pure_funcs: ['console.log']//移除console
}
}
))
.pipe(rename({ suffix: '.es.min' }))
.pipe(dest("./dist/"))
cb();
}
const iife = function (cb) {
src("./libs/index.js")
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": "entry",//兼容,依赖core-js
"corejs": '3',
"targets": '> 1%,last 2 versions,not ie <= 11',
}
],
],
"plugins": [['babel-plugin-transform-modules-iife',
{
"exportNamespace": "DisableBodyScroll"
}
]]
}))
.pipe(uglify(
{
compress: {
warnings: false,
drop_console: true, // 过滤 console
drop_debugger: true, // 过滤 debugger
pure_funcs: ['console.log']//移除console
}
}
))
.pipe(rename({ suffix: '.browser.min' }))
.pipe(dest("./dist/"))
cb();
}
const umd = function (cb) {
src("./libs/index.js")
.pipe(babel({
"presets": [
[
"@babel/preset-env",
{
"useBuiltIns": false,//兼容,依赖core-js
"modules": "umd",
"corejs": '3',
"targets": '> 1%,last 2 versions,not ie <= 11',
}
]
]
}))
.pipe(uglify({
compress: {
warnings: false,
drop_console: true, // 过滤 console
drop_debugger: true, // 过滤 debugger
pure_funcs: ['console.log']//移除console
}
}))
.pipe(rename({ suffix: '.amd.min' }))
.pipe(dest("./dist"))
cb();
}
exports.default = series(es6, umd, iife);