-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
70 lines (63 loc) · 2.15 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
const { series, src, dest } = require("gulp");
const sass = require("gulp-sass")(require("sass"));
const autoprefixer = require("gulp-autoprefixer");
const project = require("./package.json");
const rename = require("gulp-rename");
const jsonModify = require("gulp-json-modify");
const zip = require("gulp-zip");
function scss() {
return src("src/scss/**/main.scss")
.pipe(sass().on("error", sass.logError))
.pipe(rename(project.name + ".css"))
.pipe(autoprefixer())
.pipe(dest("dist/GoogleChrome/css/"))
.pipe(dest("dist/MozillaFirefox/css/"));
}
function manifestGoogleChrome() {
return src("src/manifest-chrome.json")
.pipe(jsonModify({ key: "version", value: project.version }))
.pipe(jsonModify({ key: "name", value: project.name }))
.pipe(jsonModify({ key: "description", value: project.description }))
.pipe(jsonModify({ key: "author", value: project.author }))
.pipe(rename("manifest.json"))
.pipe(dest("dist/GoogleChrome/"));
}
function manifestMozillaFirefox() {
return src("src/manifest-firefox.json")
.pipe(jsonModify({ key: "version", value: project.version }))
.pipe(jsonModify({ key: "name", value: project.name }))
.pipe(jsonModify({ key: "description", value: project.description }))
.pipe(jsonModify({ key: "author", value: project.author }))
.pipe(rename("manifest.json"))
.pipe(dest("dist/MozillaFirefox/"));
}
function images() {
return src("src/assets/**/*.*")
.pipe(dest("dist/GoogleChrome/assets/"))
.pipe(dest("dist/MozillaFirefox/assets/"));
}
function bundleGoogleChrome() {
return src([
"dist/GoogleChrome/**/*.*",
`!dist/GoogleChrome/${project.name}Chrome.zip`,
])
.pipe(zip(project.name + "Chrome.zip"))
.pipe(dest("dist/GoogleChrome/"));
}
function bundleMozillaFirefox() {
return src([
"dist/MozillaFirefox/**/*.*",
`!dist/MozillaFirefox/${project.name}Firefox.zip`,
])
.pipe(zip(project.name + "Firefox.zip"))
.pipe(dest("dist/MozillaFirefox/"));
}
exports.build = series(
scss,
manifestGoogleChrome,
manifestMozillaFirefox,
images,
bundleGoogleChrome,
bundleMozillaFirefox
);
exports.dev = series(scss, manifestGoogleChrome);