-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpFile.js
97 lines (93 loc) · 1.81 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
const {
parallel,
src,
dest
} = require("gulp"),
pump = require('pump'),
sass = require('gulp-sass'),
// concat = require('gulp-concat'),
ts = require("gulp-typescript"),
base = "./app/",
script = base + "scripts/",
appUrl = {
bg: script + "background/",
contentJs: script + "content/",
popup: script + "popup/",
options: script + "options/",
allScss: base + "scss/",
images: base + "images/",
xtras: base + "others/"
},
distUrl = "./dist",
contentJs = [
"utils",
"main",
"mode",
"view"
],
allScss = [
"content",
"popup",
"options"
];
contentJs.forEach((f, i, cf) => {
cf[i] = appUrl.contentJs + f + ".ts";
});
allScss.forEach((f, i, cf) => {
cf[i] = appUrl.allScss + f + ".scss";
});
const handleBg = function (cb) {
pump([
src([appUrl.bg + 'bgCode.ts', appUrl.bg + 'background.ts', appUrl.bg + 'cmOptions.ts']),
ts({
outFile: 'bg.min.js'
}),
dest(distUrl)
], cb);
},
handleContentJs = function (cb) {
pump([
src(contentJs),
ts({
outFile: 'content.min.js'
}),
dest(distUrl)
], cb);
},
handleContentCss = function(cb) {
pump([
src(allScss),
sass().on('error', sass.logError),
dest(distUrl)
], cb);
},
handleOptionsJs = function () {
return src(appUrl.options + '**/*.ts')
.pipe(ts())
.pipe(dest(distUrl));
},
handlePopupJs = function () {
return src(appUrl.popup + '**/*.ts')
.pipe(ts())
.pipe(dest(distUrl));
},
copyImages = function() {
return src(appUrl.images + '**/*.*')
.pipe(dest(distUrl + "/images"));
},
copyMeta = function (cb) {
return src([
appUrl.options + '*.*',
appUrl.popup + '*.*',
appUrl.xtras + '*.*'
])
.pipe(dest(distUrl));
};
// Default Build task
exports.default = parallel(handleBg,
handleContentJs,
handleOptionsJs,
handlePopupJs,
handleContentCss,
copyImages,
copyMeta);