forked from immersive-translate/old-immersive-translate
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
81 lines (71 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
const gulp = require("gulp");
const zip = require("gulp-zip");
const fs = require("fs");
const babel = require("gulp-babel");
const sourcemaps = require("gulp-sourcemaps");
gulp.task("clean", (cb) => {
fs.rmSync("dist", { recursive: true, force: true });
cb();
});
gulp.task("firefox-copy", () => {
return gulp.src(["src/**/**"]).pipe(gulp.dest("dist/firefox"));
});
gulp.task("firefox-babel", () => {
return gulp
.src(["dist/firefox/background/*.js"])
.pipe(sourcemaps.init())
.pipe(
babel({
presets: ["@babel/preset-env"],
})
)
.pipe(sourcemaps.write())
.pipe(gulp.dest("dist/firefox/background"));
});
gulp.task("firefox-zip", () => {
return gulp
.src(["dist/firefox/**/*"])
.pipe(zip("firefox.zip"))
.pipe(gulp.dest("dist"));
});
gulp.task("chrome-copy", () => {
return gulp.src(["src/**/**"]).pipe(gulp.dest("dist/chrome"));
});
gulp.task("chrome-rename", (cb) => {
fs.renameSync(
"dist/chrome/manifest.json",
"dist/chrome/firefox_manifest.json"
);
fs.renameSync(
"dist/chrome/chrome_manifest.json",
"dist/chrome/manifest.json"
);
cb();
});
gulp.task("chrome-babel", () => {
return gulp
.src(["dist/chrome/background/*.js"])
.pipe(sourcemaps.init())
.pipe(
babel({
presets: ["@babel/preset-env"],
})
)
.pipe(sourcemaps.write())
.pipe(gulp.dest("dist/chrome/background"));
});
gulp.task("chrome-zip", () => {
return gulp
.src(["dist/chrome/**/**"])
.pipe(zip("chrome.zip"))
.pipe(gulp.dest("dist"));
});
gulp.task(
"firefox-build",
gulp.series("firefox-copy", "firefox-babel", "firefox-zip")
);
gulp.task(
"chrome-build",
gulp.series("chrome-copy", "chrome-rename", "chrome-babel", "chrome-zip")
);
gulp.task("default", gulp.series("clean", "firefox-build", "chrome-build"));