-
-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathwxt.config.ts
99 lines (98 loc) · 3.19 KB
/
wxt.config.ts
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
98
99
import { vitePreprocess } from "@sveltejs/vite-plugin-svelte";
import autoprefixer from "autoprefixer";
import nesting from "postcss-nesting";
import { defineConfig, type UserManifest } from "wxt";
import { execSync } from "child_process";
import fs from "fs";
// See https://wxt.dev/api/config.html
export default defineConfig({
srcDir: "src",
manifest({ browser }) {
const url = process.env.npm_package_repository;
// @ts-expect-error Handling the input correctly
const [, author, email] = process.env.npm_package_author!.match(/(.+) <(.+)>/);
let manifest: UserManifest = {
name: browser === "edge" ? "Auto HD for YouTube" : "YouTube Auto HD + FPS",
description: "__MSG_cj_i18n_02146__",
homepage_url: url,
default_locale: "en",
host_permissions: [
"https://youtube.com/*",
"https://*.youtube.com/*",
"https://www.youtube-nocookie.com/*",
"https://youtube.googleapis.com/*"
],
permissions: ["cookies", "storage"],
// @ts-expect-error https://developer.mozilla.org/en-US/docs/Mozilla/Add-ons/WebExtensions/manifest.json/author
author: browser === "opera" || browser === "firefox" ? process.env.npm_package_author : { email }
};
if (browser === "firefox") {
manifest = {
...manifest,
browser_specific_settings: {
gecko: {
id: "[email protected]",
strict_min_version: "90.0"
}
},
developer: {
name: author,
url
}
};
} else {
// if not Firefox
manifest.offline_enabled = true;
}
return manifest;
},
hooks: {
"build:manifestGenerated"(_, manifest) {
const action = manifest.action || manifest.browser_action;
action!.default_icon = manifest.icons;
manifest.options_ui = {
page: action?.default_popup ?? "popup.html",
browser_style: true
};
},
"zip:extension:done"(_, zipPath) {
if (zipPath.match(/chrome|opera/)) {
execSync(`webext-store-incompat-fixer -i ${zipPath} --stores chrome,opera`);
} else if (zipPath.includes("edge")) {
const supportedLocales = ["en", "fr", "he", "it", "be"];
execSync(
`webext-store-incompat-fixer -i ${zipPath} --stores edge --edge-locale-inclusions ${supportedLocales}`
);
const zipAdaptedForEdge = zipPath.replace(".zip", "__adapted_for_edge.zip");
fs.unlinkSync(zipPath);
fs.renameSync(zipAdaptedForEdge, zipPath);
} else {
execSync(`webext-store-incompat-fixer -i ${zipPath} --stores firefox`);
}
}
},
outDir: "build",
outDirTemplate: "{{browser}}-mv{{manifestVersion}}-{{mode}}",
zip: {
excludeSources: ["*.env", ".env*"],
artifactTemplate: "youtube-auto-hd-fps-{{version}}-{{browser}}.zip",
sourcesTemplate: "youtube-auto-hd-fps-{{version}}-{{browser}}-source.zip"
},
modules: ["@wxt-dev/module-svelte"],
svelte: {
vite: {
preprocess: [
vitePreprocess({
script: true,
style: {
css: {
preprocessorOptions: {
plugins: [autoprefixer, nesting()]
}
}
}
})
]
}
}
});