-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
78 lines (72 loc) · 1.57 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
var gulp = require('gulp');
var dist='./client';
//js
function transjs(name,cover=90){
var browserify = require('browserify'),
buffer = require('vinyl-buffer'),
source = require('vinyl-source-stream'),
rename = require('gulp-rename'),
// babel = require('gulp-babel'),
sourcemaps = require('gulp-sourcemaps');
console.log(`compiling ${name} covers ${cover}% browsers`);
return browserify({
entries: name,
basedir:'./client/',
debug: false,
sourceType: 'module'
})
.transform(
"babelify",{
sourceMaps: true,
presets: [
["minify", {
mangle:false,
}],
[
"@babel/preset-env",{
"targets":{
"browsers":`cover ${cover}%`
},
"corejs":3,
"bugfixes":true,
"debug": true,
"useBuiltIns": 'usage'
}
],
],
plugins:[
"babel-plugin-remove-comments",
'@babel/plugin-proposal-class-properties',
"@babel/plugin-proposal-export-default-from",
]
}
)
.bundle()
.pipe(source(name))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
/* .pipe(babel({
presets:[
["minify", {
mangle:false,
}],
],
plugins:[
"babel-plugin-remove-comments",
]
})) */
.pipe(rename({extname:`.${cover}.js`}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest(dist));
}
gulp.task('js-main',function(){
return transjs('online.js',50);
});
gulp.task('js-old',function(){
return transjs('online.js',90);
});
gulp.task('js',gulp.parallel(
'js-main','js-old'
));
gulp.task('build',gulp.parallel('js'));
gulp.task('default',gulp.series('build'));