-
Notifications
You must be signed in to change notification settings - Fork 19
/
gulpfile.js
77 lines (66 loc) · 1.74 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
const gulp = require('gulp');
const pump = require('pump');
const watch = require('gulp-watch');
const sequence = require('gulp-sequence');
const uglifyES = require('gulp-uglify-es').default;
const wto = require('./src/index');
const source = [
'src/**/*.js',
'!src/converter/**/*.*',
'!src/linter/**/*.*',
'!src/adaptor/**/*.*'
];
gulp.task('baidu', () => wto.toBaidu({
source: './demo/miniprogram-demo',
target: './demo/dist/baidu-miniprogram-demo'
}));
gulp.task('alibaba', () => wto.toAlibaba({
source: './demo/miniprogram-demo',
target: './demo/dist/alibaba-miniprogram-demo'
}));
gulp.task('toutiao', () => wto.toToutiao({
source: './demo/miniprogram-demo',
target: './demo/dist/toutiao-miniprogram-demo'
}));
gulp.task('test', () => {
console.log('开始转换...');
sequence('baidu', 'alibaba', 'toutiao')(() => {
// console.log('转换完毕!');
});
});
const UGLIFY_OPTIONS = {
compress: {}
};
gulp.task('build', (cb) => {
console.log('开始转换...');
pump([
gulp.src(source),
uglifyES(UGLIFY_OPTIONS),
gulp.dest('lib')
], () => {
console.log('转换完成!');
cb && cb();
});
});
gulp.task('debug', gulp.series('build', () => watch(source, (file) => {
const path = file.history[0];
console.log('开始压缩:', path);
return gulp.src(path)
.pipe(uglifyES(UGLIFY_OPTIONS))
.pipe(gulp.dest('lib'))
.on('end', () => {
console.log('压缩完成:', path);
});
})));
gulp.task('lint', () => wto.toAll({
source: './demo/miniprogram-demo'
}));
// 实时监听
gulp.task('watch', () => {
watch('./demo/miniprogram-demo/**/*.*', () => {
wto.toBaidu({
source: './demo/miniprogram-demo',
target: './demo/dist/baidu-miniprogram-demo'
});
});
});