Skip to content
This repository has been archived by the owner on Jan 16, 2023. It is now read-only.

Commit

Permalink
support manifest v3
Browse files Browse the repository at this point in the history
  • Loading branch information
theowenyoung committed Nov 8, 2022
1 parent 06e17ba commit a7beb30
Show file tree
Hide file tree
Showing 9 changed files with 878 additions and 96 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,6 @@ start:
.Phony: build
build:
npm run build
.Phony: watch
watch:
watchexec -e js,json npm run chrome
10 changes: 8 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const babel = require("gulp-babel");
const sourcemaps = require("gulp-sourcemaps");
const manifest = require("./src/manifest.json");
const replace = require('gulp-replace');
const concat = require('gulp-concat');
gulp.task("clean", (cb) => {
fs.rmSync("dist", { recursive: true, force: true });
cb();
Expand Down Expand Up @@ -63,6 +64,12 @@ gulp.task("chrome-babel", () => {
.pipe(gulp.dest("dist/chrome/background"));
});

gulp.task("chrome-concat-background",()=>{
return gulp.src(["/lib/languages.js", "/lib/config.js", "/lib/platformInfo.js", "/background/translationCache.js", "/background/translationService.js", "/background/textToSpeech.js", "/background/chrome_background.js"].map(item=>"dist/chrome"+item))
.pipe(concat('background-entry.js'))
.pipe(gulp.dest('dist/chrome/background'));
})

gulp.task("chrome-zip", () => {
return gulp
.src(["dist/chrome/**/**"])
Expand All @@ -76,7 +83,6 @@ gulp.task("chrome-replace",()=>{
.pipe(gulp.dest("dist/chrome/options/"));
})

console.log("manifest.version", manifest.version)
gulp.task("firefox-replace",()=>{
return gulp.src(["dist/firefox/options/options.html"])
.pipe(replace("__IMMERSIVE_TRANSLATE_VERSION__",manifest.version))
Expand All @@ -88,7 +94,7 @@ gulp.task(
);
gulp.task(
"chrome-build",
gulp.series("chrome-copy", "chrome-rename", "chrome-babel", "chrome-replace","chrome-zip")
gulp.series("chrome-copy", "chrome-rename", "chrome-babel", "chrome-replace","chrome-concat-background","chrome-zip")
);

gulp.task("default", gulp.series("clean", "firefox-build", "chrome-build"));
44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
],
"scripts": {
"build": "npx gulp",
"firefox":"npx gulp firefox-build "
"firefox": "npx gulp firefox-build ",
"chrome": "npx gulp chrome-build "
},
"devDependencies": {
"@babel/core": "^7.19.3",
Expand All @@ -16,6 +17,7 @@
"@types/firefox-webext-browser": "^94.0.1",
"gulp": "^4.0.2",
"gulp-babel": "^8.0.0",
"gulp-concat": "^2.6.1",
"gulp-replace": "^1.1.3",
"gulp-sourcemaps": "^3.0.0",
"gulp-zip": "^5.1.0"
Expand Down
Loading

0 comments on commit a7beb30

Please sign in to comment.