This repository has been archived by the owner on Feb 7, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
82 lines (75 loc) · 2.67 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
const gulp = require('gulp');
const size = require('gulp-size');
const uglify = require('gulp-uglify');
const concat = require('gulp-concat');
const rename = require('gulp-rename');
const header = require('gulp-header');
const del = require('del');
const pkg = require('./package.json');
// Header Copyright Content For Minify File
const banner = `/*! ${pkg.name} | ${pkg.license} | ${pkg.version} - ${pkg.description} */\n`;
// Clean build and cache files
gulp.task('clean', async () => {
await del('dist');
});
gulp.task('clean').description = 'Clean build and cache files';
// Compound cache test file for test tools.
gulp.task('test', async () => {
await gulp.src(['./src/list.js', './src/for-test.js'])
.pipe(concat('proxy-pac.test.js'))
.pipe(gulp.dest('./test/'))
.pipe(size({
showFiles: true
}));
await gulp.src(['./src/gfwlist.js', './src/for-test.js'])
.pipe(concat('gfwlist.test.js'))
.pipe(gulp.dest('./test/'))
.pipe(size({
showFiles: true
}));
});
gulp.task('test').description = 'Compound cache test file for Travis test';
// Compound proxy-pac.js file
gulp.task('main', async () => {
await gulp.src(['./src/list.js', './src/pac-main.js'])
.pipe(concat('proxy-pac.js'))
.pipe(gulp.dest('./dist/'))
.pipe(size({
showFiles: true
}));
await gulp.src(['./src/gfwlist.js', './src/pac-main.js'])
.pipe(concat('gfwlist-pac.js'))
.pipe(gulp.dest('./dist/'))
.pipe(size({
showFiles: true
}));
});
gulp.task('main').description = 'Compound proxy-pac.js file';
// Minify file & Generate proxy-pac.min.js
gulp.task('min', async () => {
await gulp.src('./dist/proxy-pac.js')
.pipe(uglify())
.pipe(header(banner))
.pipe(rename({
basename: 'proxy-pac',
suffix: '.min'
}))
.pipe(gulp.dest('./dist/'))
.pipe(size({
showFiles: true
}));
await gulp.src('./dist/gfwlist-pac.js')
.pipe(uglify())
.pipe(header(banner))
.pipe(rename({
basename: 'gfwlist-pac',
suffix: '.min'
}))
.pipe(gulp.dest('./dist/'))
.pipe(size({
showFiles: true
}));
});
gulp.task('min').description = 'Minify file & Generate proxy-pac.min.js';
// Default task
// gulp.task('default', gulp.series('main', gulp.series('min')));