-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgulpfile.js
More file actions
111 lines (99 loc) · 2.29 KB
/
Copy pathgulpfile.js
File metadata and controls
111 lines (99 loc) · 2.29 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
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
99
100
101
102
103
104
105
106
107
108
109
110
111
'use strict';
let gulp = require("gulp");
let rollup = require('gulp-rollup');
let babel = require("gulp-babel");
let minify = require('gulp-minify');
let zipmd5 = require("gulp-zipmd5");
let clean = require("gulp-clean");
let gulpSequence = require('gulp-sequence');
gulp.task('copy', function(cb) {
gulp.src('src/lib/*').pipe(gulp.dest('dist/lib/'));
});
gulp.task("arthur", ["build"], () => {
gulp
.src("arthur", {read: false})
.pipe(clean());
return gulp
.src("dist/**/*")
.pipe(zipmd5('output.zip'))
.pipe(gulp.dest('arthur/'));
});
gulp.task('bundle-umd', function(cb) {
gulp.src('./src/*.js')
.pipe(rollup({
allowRealFiles: true,
input: './src/index.js',
format: 'umd',
name: 'flexPolyfill'
}))
.pipe(gulp.dest('./bundle'))
.on('end', cb);
});
gulp.task('bundle-cjs', function(cb) {
gulp.src('./src/*.js')
.pipe(rollup({
allowRealFiles: true,
input: './src/index.js',
format: 'cjs'
}))
.pipe(gulp.dest('./bundle'))
.on('end', cb);
});
gulp.task('babel', function(cb) {
gulp.src("bundle/index.js")
.pipe(babel({
presets: ['es2015-script']
}))
.pipe(gulp.dest("bundle"))
.on('end', cb);
});
gulp.task('babel-es', function(cb) {
gulp.src("bundle/index.js")
.pipe(babel({
presets: ['es2015']
}))
.pipe(gulp.dest("bundle"))
.on('end', cb);
});
gulp.task('minify-es', function(cb) {
gulp.src('bundle/index.js')
.pipe(minify({
ext: {
min: '.js'
},
noSource: true
}))
.pipe(gulp.dest('lib/'))
.on('end', cb);
});
gulp.task('minify-umd', function(cb) {
gulp.src('bundle/index.js')
.pipe(minify({
ext: {
min: '.min.js'
},
noSource: true
}))
.pipe(gulp.dest('dist/'))
.on('end', cb);
});
// 用于独立文件版本的打包
gulp.task("build", function () {
gulpSequence('bundle-umd', 'babel', 'minify-umd', 'copy')((err) => {
if (err) {
console.log('build fail: ', err);
} else {
console.log('build done!');
}
});
});
// 用于发布到NPM的打包
gulp.task('publish', function() {
gulpSequence('bundle-cjs', 'babel-es', 'minify-es')((err) => {
if (err) {
console.log('publish fail: ', err);
} else {
console.log('publish done!');
}
});
});