-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
71 lines (63 loc) · 1.91 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
const { series, parallel } = require("gulp");
const rm = require("rimraf");
const { src, dest } = require("vinyl-fs");
const path = require("path");
const zip = require("gulp-zip");
const minify = require("gulp-minify");
const concat = require("gulp-concat");
const OUTPUT_PATH = "./dist";
const FF_SRC_PATH = "./src_ff";
const CHROME_SRC_PATH = "./src_chrome"
const SHARED_SRC_PATH = "./src_shared"
function clean(cb) {
rm(OUTPUT_PATH, () => {
cb();
});
}
function build_firefox() {
return src(addFileExpression(FF_SRC_PATH))
.pipe(src(addFileExpression(SHARED_SRC_PATH)))
.pipe(concat("background.js"))
.pipe(minify(
{
ext:{
src:'-debug.js',
min:'.js'
},
noSource: true
}))
.pipe(src(FF_SRC_PATH + "/*.json"))
.pipe(dest(path.join(OUTPUT_PATH, "firefox")));
}
function build_chrome() {
return src(addFileExpression(CHROME_SRC_PATH))
.pipe(src(addFileExpression(SHARED_SRC_PATH)))
.pipe(concat("background.js"))
.pipe(minify(
{
ext:{
src:'-debug.js',
min:'.js'
},
noSource: true
}))
.pipe(src(CHROME_SRC_PATH + "/*.json"))
.pipe(dest(path.join(OUTPUT_PATH, "chrome")));
}
function addFileExpression(path) {
let fileTypes = ['/*.js']
return fileTypes.map(type => path + type);
}
function archive_firefox() {
return src(addFileExpression(path.join(OUTPUT_PATH, "firefox")))
.pipe(src(FF_SRC_PATH + "/*.json"))
.pipe(zip("firefox.zip"))
.pipe(dest(OUTPUT_PATH));
}
function archive_chrome() {
return src(addFileExpression(path.join(OUTPUT_PATH, "chrome")))
.pipe(src(CHROME_SRC_PATH + "/*.json"))
.pipe(zip("chrome.zip"))
.pipe(dest(OUTPUT_PATH));
}
exports.build = series(clean, parallel(build_firefox, build_chrome), parallel(archive_firefox, archive_chrome));