-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmanifest.ts
71 lines (60 loc) · 1.57 KB
/
manifest.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
import { PluginOption } from "vite";
import path from "path";
import fs from "fs";
const publicDir = path.resolve(__dirname, "./public");
const manifestConfig = (projectVersion: string): chrome.runtime.ManifestV3 => {
return {
manifest_version: 3,
name: "Assistant",
version: projectVersion,
description: "Assistant",
icons: {
"16": "logo.png",
"32": "logo.png",
"48": "logo.png",
"128": "logo.png",
},
content_scripts: [
{
js: ["content/index.js"],
matches: ["<all_urls>"], // TODO limit only for specific site
exclude_matches: ["*://localhost:*/*"], // ! Exclude localhost when developing
},
],
action: {
default_icon: "logo.png",
default_title: "Assistant",
},
options_page: "setting.html",
background: {
service_worker: "service/index.js",
},
host_permissions: ["http://*/*", "https://*/*"],
permissions: ["scripting", "tabs"],
web_accessible_resources: [
{
resources: ["assets/js/*.js", "assets/css/*.css", "logo.png"],
matches: ["*://*/*"],
},
],
};
};
function vitePlugin(projectVersion: string): PluginOption {
function makeManifest(to: string) {
if (!fs.existsSync(to)) {
fs.mkdirSync(to);
}
const manifestPath = path.resolve(to, "manifest.json");
fs.writeFileSync(
manifestPath,
JSON.stringify(manifestConfig(projectVersion), null, 2)
);
}
return {
name: "manifest",
buildStart() {
makeManifest(publicDir);
},
};
}
export default vitePlugin;